所以,我试图用一个线性布局来保存三个不同的按钮,每个按钮在一条线上应占用33%的宽度。此线性布局将低于我的相对布局中的所有其他内容,该布局包含此活动中的所有其他小部件。不幸的是,当我将第三个按钮添加到布局中时,另外两个按钮的底部有一个白色条,第三个按钮(在这种情况下为主页按钮)的位置高于其他按钮。三个按钮均匀分布线性布局
有人可以解释这种行为,以及如何纠正它?谢谢。
这是线性布局的XML文件,我已经删除了其他小部件的所有文本。如果这会有所帮助,我也可以发布。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<Button
android:layout_width="0dp"
android:layout_weight=".33"
android:layout_height="wrap_content"
android:text="@string/adfazsdfasdfadfsagjlfkdlgjklfsadgfjgps"
android:onClick="resetDates"
android:background="@drawable/sumbitstyleing"
android:id="@+id/resetDatesButton" />
<Button
android:layout_width="0dp"
android:layout_weight=".33"
android:layout_height="wrap_content"
android:text="@string/home"
android:onClick="home"
android:id="@+id/homeButtonSearch"
android:background="@drawable/generalbutton" />
<Button
android:layout_weight=".33"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/submitchanges"
android:onClick="submitChanges"
android:background="@drawable/sumbitstyleing"
android:id="@+id/submitchanges" />
</LinearLayout>
第一张照片没有第三个按钮,第二张照片是第三个按钮。
请勿使用alignParentEnd和alignParentRight。首先,这两个将在LTR语言中发生冲突。其次,由于您的宽度为match_parent,因此您将自动对齐到父项的两侧。 (alignParentBottom很好,它不冲突)。 –
将'android:baselineAligned =“false”'添加到'LinearLayout'以使'Button's排队。我不确定白线是什么。某种渲染故障?这可能是模拟器还是布局设计器? –
可能重复[是否有可能在android linearlayout的宽度上均匀分布按钮](http://stackoverflow.com/questions/3470420/is-it-possible-to-evenly-distribute-buttons-across-the -width-的-AN-机器人-LINEA) – mbmc