2013-11-28 7 views
0

Я новичок в Android, Im пытается установитьlayout_weight в андроиде не работает

android:layout_weight="1" 

на editView.

Прежде всего, это довольно странно, потому что я не вижу его в окне свойств.

и когда я поставил его на код, он не делает ничего

это мой код:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context=".StatusActivity" > 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:layout_marginLeft="18dp" 
    android:layout_marginTop="19dp" 
    android:text="TextView" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/textView1" 
    android:layout_alignRight="@+id/editText1" 
    android:layout_marginRight="19dp" 
    android:text="TextView" /> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/editText1" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="59dp" 
    android:text="Button" /> 

<EditText 
    android:id="@+id/editText1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_below="@+id/textView1" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="28dp" 
    android:ems="10" 
    android:layout_weight="1" /> 

почему же layout_weight не показывает в окне Properites? и почему он ничего не делает, когда я помещаю его в код?

+1

'layout_weight' предназначен для' LinearLayout', 'RelativeLayout' игнорирует его. –

+0

, поэтому упаковка должна быть линейной? – thormayer

+1

Я не знаю, какой дизайн вы пытаетесь достичь, поэтому я не могу прокомментировать :) Но да, для того, чтобы ваш 'layout_weight' был соблюден, содержащий макет должен быть' LinearLayout' –

ответ

0

Вы будете использовать только компоновщиков вес для линейной компоновки.

И другая вещь вы кладете weightsum равно некоторое значение к линейной компоновке и распределять поровну вес мнения с помощью макета веса.

0

Присвоение веса макете допускается только для Linear Layout. Остальные макеты будут игнорировать это.

Смежные вопросы