所以,我試圖用一個線性佈局來保存三個不同的按鈕,每個按鈕在一條線上應占用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