gpt4 book ai didi

android - "android:layout_column"属性是什么?

转载 作者:行者123 更新时间:2023-11-29 18:13:57 24 4
gpt4 key购买 nike

main.xml 文件代码:

<TableRow 
android:id="@+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:text="User"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>

<EditText
android:text=""
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

></EditText>

<TextView
android:text="Test"
android:id="@+id/usernameTest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

></TextView>

</TableRow>

<TableRow
android:id="@+id/TableRow05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:text="Hobby"
android:id="@+id/hobby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>

<CheckBox
android:text="A"
android:id="@+id/reading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
></CheckBox>
<CheckBox
android:text="B"
android:id="@+id/swimming"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
></CheckBox>


</TableRow>

我看过官方的 android 文档,从中我了解到,android:layout_column 表示这个 child 应该在的列的索引。 我已经在两个CheckBox上设置了属性:android:layout_column = "1",所以我想到了两个CheckBox应该都在第二列(索引:1)。但令我惊讶的是,第一个 CheckBox 在第二列,第二个 CheckBox 在第三列,如下所示: enter image description here

谁能解释一下为什么?

最佳答案

您不能将两个 Views 放在同一列中。第一个 CheckBox 进入第 1 列,因为您使用 android:layout_column = "1" 设置它,第二个 CheckBox 自动放置在第 2 列。

编辑:如果您确实希望您的复选框在同一列中,您可以用 LinearLayout 包裹它们,然后设置 android:layout_column = "1 " 用于 LinearLayout

关于android - "android:layout_column"属性是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9223683/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com