gpt4 book ai didi

android - 如何创建 3 个等宽的 TextView,它们在屏幕上填充父级

转载 作者:太空宇宙 更新时间:2023-11-03 12:25:37 24 4
gpt4 key购买 nike

你好,

你能告诉我如何创建 3 个同样宽的 TextView 来填充屏幕上的父级吗?我尝试这样做,但 TextView 的宽度不同:它是 149、89、89。

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:stretchColumns="*"
android:shrinkColumns="*">

<TextView android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"/>

<TextView android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"/>

<TextView android:id="@+id/t3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"/>

最佳答案

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
/>
</LinearLayout>

关于android - 如何创建 3 个等宽的 TextView,它们在屏幕上填充父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2814223/

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