如何在android中水平和垂直滚动表格布局
问题描述:
我在表格布局中完全困惑。我必须实现水平和垂直滚动的表格。我也看到表修复头示例,但tablefixheader示例已使用适配器来设置数据,但我需要表格布局中的添加视图方法。 我用下面的代码,但它不能支持双向滚动如何在android中水平和垂直滚动表格布局
<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>
答
这是我如何实现它和我的作品:
<?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>
这个代码看看,看看这个帮助。
答
添加这样
<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>
感谢和它的作品真棒...... – user1811379
@ user1811379,欢迎你,有一个很好的编码。 –
很棒的+1。你应该添加一点解释它为什么工作=) – user2336315