gpt4 book ai didi

android - android :layout_column do?到底是什么

转载 作者:IT老高 更新时间:2023-10-28 22:22:02 25 4
gpt4 key购买 nike

我正在学习 android,并且正在努力理解这个特定的布局属性,阅读它说的 google dev 文档:

android:layout_column

The index of the column in which this child should be. Must be an integer value, such as "100". This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type. This corresponds to the global attribute resource symbol layout_column.

谁能解释这如何映射到等效的 html (因为表格行似乎从它们那里大量借用)?

是它所支持的列数 - 例如 colspan?

最佳答案

呃,它的意思是“这个 child 应该在的列的索引”。唯一棘手的部分是列从 0 开始。

例如:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<TextView
android:text="URL:" />
<EditText android:id="@+id/entry"
android:layout_span="3"/>
</TableRow>
<TableRow>
<Button android:id="@+id/cancel"
android:layout_column="2"
android:text="Cancel" />
<Button android:id="@+id/ok"
android:text="OK" />
</TableRow>
</TableLayout>

上述布局中的两行都有四列。第一个有四列,因为它在第 0 列中有一个 TextView 和一个跨越第 1、2 和 3 列的 EditText。第二个有四列,因为它跳过了列0 和 1 并将两个 Button 小部件放在第 2 列和第 3 列中,由第一个 Button 中的 android:layout_column="2" 属性提供>.

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

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