首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在android中实现水平和垂直滚动表格布局

如何在android中实现水平和垂直滚动表格布局
EN

Stack Overflow用户
提问于 2013-05-18 18:40:03
回答 2查看 45.5K关注 0票数 24

我完全搞不懂表格布局卷轴。我必须实现水平和垂直滚动表格。我也见过表修复标题示例,但tablefixheader示例使用了适配器来设置数据,但我需要在表布局中使用add-view方法。我使用了下面的代码,但它不能支持双向滚动

代码语言:javascript
复制
      <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scrollbars="vertical" >

        <HorizontalScrollView
            android:layout_width="match_parent"
            android:layout_height="fill_parent" 
            android:fadeScrollbars="false">

            <TableLayout
                android:id="@+id/tableLayoutId"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </HorizontalScrollView>
    </ScrollView>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-05-18 18:50:32

这是我实现它的方式,对我来说是有效的:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
 <ScrollView 
    android:id="@+id/layout" 
    android:layout_height="match_parent"         
    android:scrollbars="horizontal|vertical" 
    android:layout_width="match_parent"     
    android:layout_marginTop="5dip"     
    android:scrollbarStyle="outsideInset"
    android:fillViewport="true"> 

    <HorizontalScrollView 
        android:id="@+id/horizontalView" 
        android:layout_height="wrap_content"     
        android:scrollbars="horizontal|vertical" 
        android:layout_width="wrap_content"     
        android:layout_marginTop="5dip">

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/tlGridTable" >   
        </TableLayout>
    </HorizontalScrollView>
</ScrollView>
</LinearLayout>

看一下这段代码,看看这是否有帮助。

票数 63
EN

Stack Overflow用户

发布于 2017-09-20 19:58:32

像这样添加

代码语言:javascript
复制
<ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scrollbars="vertical">

        <HorizontalScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/rv_pins"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbarStyle="outsideOverlay"
                android:scrollbars="horizontal" />
        </HorizontalScrollView>

    </ScrollView>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16623337

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档