我有這樣的佈局,一個對話框內:當使用重量的LinearLayout和3個按鈕,中間按鈕是有點低
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="@+id/button2"
android:layout_marginBottom="10dp"/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:text=""
android:background="@android:color/transparent"
android:clickable="false"
android:enabled="false"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:orientation="horizontal"
android:layout_below="@+id/rView"
android:weightSum="3">
<Button
android:id="@+id/okbutton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/ok"
android:background="@drawable/buttonshape"
android:layout_weight="1"
android:textColor="@color/blanco"/>
<Button
android:id="@+id/markall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/checkall"
android:background="@drawable/buttonshape"
android:layout_weight="1"
android:textColor="@color/blanco"/>
<Button
android:id="@+id/cancelbutton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/cancel"
android:background="@drawable/buttonshape"
android:layout_weight="1"
android:textColor="@color/blanco"/>
</LinearLayout>
這是我使用作爲背景被拉伸:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners
android:radius="50dp"
/>
<solid
android:color="@color/botones"
/>
<stroke
android:width="0dp"
android:color="#878787"
/>
中的LinearLayout裏面有3個按鍵,你可以看到。他們每個人都應該在線性佈局中使用相同數量的空間,而且他們實際上是這樣做的,但中央按鈕(markall)與其他人不一致,有點低,就像5dp或類似的東西。我不知道爲什麼會發生這種情況,以及如何解決這個問題。
任何幫助?
謝謝。
我認爲它的做工精細的外觀截圖:HTTP:// prntscr。 com/gnf4vn –
是的,我知道它應該工作,但不適合我。 – Fustigador
你不能使用_wrap_content_,因爲你使用的是重量 – Piyush