我在布局上有两个按钮,在大屏幕设备(平板电脑)上,我想限制它们的宽度,以免它们看起来很荒谬。我希望使用 maxWidth 属性,但它显然在我的场景中没有任何作用。这是布局定义 - 按钮用完布局的整个宽度,忽略 maxWidth 中的任何值。
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxWidth="100dp"
android:text="Button 1"
/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxWidth="100dp"
android:text="Button 2"
/>
</LinearLayout>
为什么,以及如何解决这个(显然是疯狂的)限制?