【发布时间】:2018-04-28 13:20:11
【问题描述】:
我的Linear Layout 中有四个textviews,它们相等
宽度如下,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView86" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="0.25"
android:layout_height="wrap_content" />
<TextView
android:layout_width="0dp"
android:layout_weight="0.25"
android:layout_height="wrap_content" />
<TextView
android:layout_width="0dp"
android:layout_weight="0.25"
android:layout_height="wrap_content" />
<TextView
android:layout_width="0dp"
android:layout_weight="0.25"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
我的问题是,文本视图应该以相同的高度显示。该文本视图的内容(文本)将以编程方式设置。我尝试使用Relative layout,但textview 的width 不能相同。我需要高度和宽度都应与最高的孩子相同。
请指导我。谢谢!
【问题讨论】:
-
为您的布局提供完整代码。您可以在父布局中使用 layout_weight 来获取结果。
-
你想让 textxtview 水平对齐还是垂直对齐?
-
就像,在一行中,它们应该以相同的高度和宽度显示。