我有一个水平的LinearLayout
与两个按钮与文本里面。 LinearLayout
和按钮layout_height
是wrap_content
。儿童的意见有相等的高度
两个按钮之一的文本需要两行,不同于其他行需要一行。
所以最后一个按钮的高度比另一个更大,这是我不想要的。
我知道如何以编程方式解决这个问题。所以我提出这个问题的原因是要知道我是否可以通过xml解决这个问题。
一个可行的办法是,对于其文字是一行按钮,设置
layout_height="match_parent"
,它工作正常。
但这里的问题是,我通常不知道哪个按钮将占据最大的高度。
实质上我想要做的是:在内部有一个带有视图的LinearLayout 我希望将所有子视图的高度设置为等于视图的高度,当视图的内容被包装时具有最大高度。
而问题是如果这是可能的通过XML?
一个示例XML。另外我忘了补充说我已经有宽度0dp。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/some_string" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/some_other_string" />
</LinearLayout>
为了谁提议的编辑之一:抱歉,它自动拒绝,因为我做了一个后来编辑。 如果您可以再次发布,我会接受它。 – Abomin
请添加您的布局xml – USKMobility
尽管问题更一般,我会添加一个示例。 – Abomin