thormayer
thormayer

Reputation: 1070

layout_weight in android is not working

I am new to Android, Im trying to set an

android:layout_weight="1"

on editView .

first of all, its quite odd, because I cant see it on the properties window.

and when I set it on the code, it does not do anything

this is my code :

<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" />

why does the layout_weight doesnt show in the properites window ? and how come does it doesnt do anything when I place it on the code?

Upvotes: 0

Views: 85

Answers (3)

Pihu
Pihu

Reputation: 1039

Assigning weight to layout is only eligible for Linear Layout. Rest of the layouts will ignore this.

Upvotes: 0

Born To Win
Born To Win

Reputation: 3329

You will only use layout-weight for Linear layout.

And other thing is you put an weightsum is equal to some value to Linear layout and distribute equally weight to the views by using layout-weight.

Upvotes: 0

Semyon Danilov
Semyon Danilov

Reputation: 1773

layout_weight is for views in LinearLayout

Upvotes: 2

Related Questions