gpt4 book ai didi

android - 如何在我的 Android 应用程序中使 View 填充其父级的整个宽度?

转载 作者:IT老高 更新时间:2023-10-28 23:26:29 24 4
gpt4 key购买 nike

我为我的一项 Activity 定义了以下布局:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<TableRow android:id="@+id/TableRow01" android:layout_height="wrap_content" android:layout_width="fill_parent">
<EditText android:text="Resource Name" android:id="@+id/ResourceName" android:lines="1" android:isScrollContainer="false"></EditText>
</TableRow>
<TableRow android:id="@+id/TableRow02" android:layout_height="wrap_content" android:layout_width="fill_parent">
<Button android:id="@+id/Tile" android:text="Tile"></Button>
</TableRow>
</TableLayout>

布局呈现几乎正确,唯一的问题是我的文本框和我的按钮没有占据它们各自行的整个宽度。

我尝试为布局宽度属性指定 fill_parent,但无济于事,它们仍然只占屏幕的大约一半。

到目前为止,Android 的整体文档都很棒,但是有一些像这样的场景,我碰到了一堵看不见的墙!感谢大家的帮助!

最佳答案

尝试使用 android:stretchColumns="0"(当您定义 TableLayout 时)或您想要拉伸(stretch)的列的索引。

更多信息 - http://developer.android.com/guide/tutorials/views/hello-tablelayout.html

关于android - 如何在我的 Android 应用程序中使 View 填充其父级的整个宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2405614/

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