請看看下面的代碼如何將按鈕對齊到LinearLayout的最右角?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#373734"
android:orientation="horizontal" >
<ImageView
android:id="@+id/backToLanguageSelectionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="15dp"
android:paddingTop="5dp"
android:src="@drawable/thunderbolt" />
<ImageView
android:id="@+id/internetButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:src="@drawable/globe_small_2" />
<Button
android:id="@+id/giveUpButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="350dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:text="Button" />
</LinearLayout>
這是我使用所有的Android活動的共同佈局代碼。問題在於按鈕,我希望它移動到最右邊的角落。保證金的東西似乎不能正常工作,因爲在不同的設備中,按鈕位於不同的地方。
如何將其移動到所有設備中顯示的最右側角落?
好吧,這是超級棒!謝謝! –
它的工作。這是如何工作的?如果我得到解釋,將會有所幫助。通過將0dp設置爲的寬度,它在按鈕之間創建了最大空間。怎麼樣 ???? –
Pravin
好吧,layout_weight顯然。 「這個屬性爲視圖指定了一個」重要性「的值,它應該佔用多少空間在屏幕上。」來自LinearLayout文檔。 – Nerkatel