安卓用户界面 : Multiple Horizontally Paged Table

标签 android user-interface landscape tablelayout

我正在尝试实现一个 UI,其中包含使用 TableLayout 显示的数据表(动态填充)。我希望默认显示表格的 4 列,并能够水平滚动表格以显示 4(或更多)个附加列。将 TableLayout 与水平/垂直 ScrollView 结合使用是否可行?如果有任何展示这种风格的 XML 示例,我将不胜感激。

这里有一个例子来说明:

默认表格 View enter image description here

向右滚动后查看 enter image description here

最佳答案

您应该能够通过将 TableLayout 放在 Horizo​​ntalScrollView 中来实现这一点。在 TableLayout 中定义元素的宽度

像这样的(我没有测试过):

<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/hsv1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

    <TableLayout android:layout_height="wrap_content" 
           android:gravity="center" 
           android:layout_width="wrap_content"  
           android:id="@+id/tl1" 
           android:scrollbars="horizontal">

        // Your other elements go here.

    </TableLayout>
</HorizontalScrollView>

关于安卓用户界面 : Multiple Horizontally Paged Table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6363743/

相关文章:

c++ - Pixbuf 显示有关图像的错误信息

Android - fragment 还是自定义 View ?我应该使用哪个?

java - Google Drive Api result.getStatus().isSuccess() 始终为真

android - 查找和替换 Android Studio

c++ - 如何更改 QTableWidget 的最小尺寸?

python - 如何在PyQt5中横向打印?

android - 如何在首次启动应用程序时检测方向模式

Android ActionBar 不显示图标

android - RxJava - 何时以及为何使用 Observable.share()

c - 大型 C 程序的 GUI 方法