2014-01-16 27 views
0

我想在偏好活動中有兩個偏好並排。一個例子是這樣的:Nebulander並排pref android

我想:

imagepref2.xml:

image 從壁紙得到

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:paddingBottom="15dip" 
    android:paddingTop="15dip" > 

    <ImageView 
     android:id="@+id/thumb_1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_weight="1" 
     android:src="@drawable/img_1" /> 

    <ImageView 
     android:id="@+id/thumb_2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_weight="1" 
     android:src="@drawable/img_2" > 
    </ImageView> 
</LinearLayout> 

但是,這顯示爲: this

+0

您能解釋一下更多有關您的佈局的問題?我認爲結果完全符合您在佈局XML中定義的內容。 – nKn

回答

0

我想這是因爲你的android:layout_weight="1"是1. 更改爲0.5。 並將android:layout_width="wrap_content"更改爲android:layout_width="0dp"

+1

如果在這種情況下layout_weight是1或0.5,那麼無關緊要,因爲'LinearLayout'沒有定義任何'weightSum'屬性。 – nKn

+0

刪除重力線,並在線性佈局上放置layout_gravity =「center」。 (抱歉,我沒有與我的機器人,但我嘗試幫助你) – VincentLamoute

+0

訣竅是:** android:layout_width =「0dp」**,你可以將權重留給** 1 ** –