请看这里的XML代码:
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
xmlns:android="http://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"
但它并不能完成这项工作。有办法吗?
发布于 2011-06-29 06:19:19
将整个过程包含在:
<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>
发布于 2014-08-27 08:37:21
从技术上讲,您不需要在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中占据了足够的空间,滚动效果就会激活(有点像超文本标记语言的TextArea,一旦你有足够的文本行,滚动就会激活)。
您也可以嵌套ScrollView,但是在ScrollView中有足够的内容之前,您仍然无法感受到滚动效果。
发布于 2014-12-26 19:58:06
谢谢mbauer,它解决了我的问题,我把它放在首位
带end的
的页眉
https://stackoverflow.com/questions/6513718
复制相似问题