layout_gravity not working inside LinearLayout

android, android-layout

Solution

Changing the textView to this worked for me

<TextView
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:gravity="top"
    android:layout_weight="1"
    android:text="TEST" />

This takes advantage of gravity instead of layout_gravity, but since the textView's height is set to fill_parent it has the same effect

android:gravity sets the gravity of the content of the View its used on. android:layout_gravity sets the gravity of the View or Layout in its parent.

Problem

I've got the following code: ``` <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <EditText android:id="@+id/editText1" android:layout_width="0dp" android:layout_height="150dp" android:layout_weight="3" android:inputType="textMultiLine" > </EditText> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="top" android:layout_weight="1" android:text="@string/new_post_txt_description" /> </LinearLayout> ``` Apparently `android:layout_gravity="top"` does not moves the `TextView` to the up. Anyone knows how to achieve that? P.S I saw some ideas about using `RelativeLayout`, but in my case i need both of the controls to be next to each other and use weight attribute as in the example. Thanks!

Original source