[英]LinearLayout space between 2 buttons
這是我的linearLayout:
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ANNULLA"
android:id="@+id/button4"
android:layout_gravity="bottom"
android:textColor="#FFF"
android:background="#87a914"
android:textStyle="bold"
android:textSize="20dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="3dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="SALVA"
android:id="@+id/button5"
android:layout_gravity="bottom"
android:textColor="#FFF"
android:background="#87a914"
android:textStyle="bold"
android:textSize="20dp"
android:layout_marginBottom="2dp"
android:layout_marginRight="3dp" />
</LinearLayout>
結果是:
我想在按鈕“ SALVA”和按鈕“ ANNULLA”之間留一個空格
我的意思是這樣的:
只需在第二個按鈕中添加此屬性
android:layout_marginLeft="xdp"
我最喜歡的方法是在按鈕之間添加不可見視圖,如下所示:
<View android:layout_width="5dp" android:layout_height="wrap_content" android:visibility="invisible" />
一種方法是在它們之間以合適的weight
添加一個空View
<View
android:layout_width="0dp"
android:layout_height-"wrap_content"
android:layout_weight=".2"/> // change this to what works for you
使用layout_weight
時, Buttons
的width
應為“ 0dp”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.