在滚动视图中使用 Table 布局

Use of Table Layout inside scroll view

你好我是android
的新人 我试图使用滚动视图,在互联网上的某处我发现了这段代码

<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" 或任何数字,我的 scroll view.

不会有任何变化

TableLayout 可以通过调用 setColumnShrinkable()(xml:android:shrinkColumns) 或 setColumnStretchable()(xml:android 将某些列指定为可收缩或可拉伸:stretchColumns).

如果标记为可收缩,则可以收缩列宽以适应 table 到其父对象。如果标记为可拉伸,它可以扩展宽度以适应任何额外的 space.

table 的总宽度由其父容器定义。重要的是要记住,列既可以收缩又可以拉伸。

详细信息您可以访问

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"/>