请在这里查看XML代码:
<TableLayout android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dip" xmlns:android="https://schemas.android.com/apk/res/android"> <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content"> <!-- Some stuff goes here --> /> </TableRow> <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content"> <!-- Some stuff goes here --> /> </TableRow> <TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content"> <!-- Some stuff goes here --> /> </TableRow> </TableLayout>
我的代码比这个长得多,但我只是消除了不必要的部分。 问题是我想让这个TableLayout
滚动,以便我的东西都可以显示。
我试图把这行放在TableLayout
为了使其滚动:
android:isScrollContainer="true"
但是这并不能完成这项工作。 有没有办法?
整个事情包括在:
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="none" android:layout_weight="1"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> ... </ScrollView>
您在技术上不需要ScrollView中的LinearLayout:
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="none" android:layout_weight="1"> <TableLayout android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dip" android:isScrollContainer="true"> <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content"> <--!Everything Else You Already Have--> </TableRow> </TableLayout> </ScrollView>
一旦你在ScrollView中占用了足够的空间,滚动效果就会被激活(有点像HTML TextArea,一旦你有足够的文本行,滚动就会激活)。
您也可以嵌套滚动视图,但是在滚动视图中有足够的内容之前,您再也无法感受到滚动效果。
感谢mbauer它解决了我的问题,我sorting
以上就是android开发分享如何使一个可滚动的TableLayout?相关内容,想了解更多android开发(异常处理)及android游戏开发关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/addevelopment/514234.html