你好,我是安卓新手
我试图使用 ScrollView ,在互联网上的某个地方我找到了这段代码
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1">
这段代码工作完美,但我不明白有什么用
android:stretchColumns="1">
?如果我将 stretchColumns="1"
更改为 "3"
或任何我没有得到的数字我的 ScrollView
中的任何更改。
最佳答案
TableLayout 可以通过调用 setColumnShrinkable()(xml:android:shrinkColumns) 或 setColumnStretchable()(xml:android:stretchColumns) 将某些列指定为可收缩或可拉伸(stretch)。
如果标记为可收缩,则可以收缩列宽以适合表格到其父对象。如果标记为可拉伸(stretch),它可以扩展宽度以适应任何额外空间。
表格的总宽度由其父容器定义。请务必记住,列既可以收缩又可以拉伸(stretch)。
详情请访问
https://developer.android.com/reference/android/widget/TableLayout.html
看看这个例子
<TableLayout
android:shrinkColumns="2,3"
android:stretchColumns="1,3"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
关于android - 在 ScrollView 中使用表格布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42993392/