2014-01-16 1 views
0

Я хотел бы иметь две настройки бок о бок в деятельности предпочтения. Примером может служить следующее:бок о бок pref android

image получил от обоев: Nebulander

Я попытался:

imagepref2.xml:

<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 ** –