Silvio Marijic
Silvio Marijic

Reputation: 481

Android layout above issue

iam designin new app , and at some part i need two layouts on top of each other , but not using arndroid:orientation , insted of that i need to use layout_above/layout_below , but it says to me is a invalid parameter for LinearLayout here is the code

<LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/menu"
        android:gravity="center">
            <LinearLayout
                android:id="@+id/t1"  
                android:layout_width="80dp"
                android:gravity="center"
                android:layout_height="80dp"
                android:background="#DDDDDD">

            </LinearLayout>
            <LinearLayout
                android:id="@+id/t2"  
                android:layout_width="80dp"
                android:gravity="center"
                android:layout_height="80dp"
                android:background="#DDDDDD">

            </LinearLayout>
            <LinearLayout
                android:id="@+id/t3"  
                android:layout_width="80dp"
                android:gravity="center"
                android:layout_above="@id/t1"
                android:layout_height="80dp"
                android:background="#DDDDDD">

            </LinearLayout>


    </LinearLayout>

so linear layouts t1 and t2 are next to each other witch is fine , but i want linearlayout t3 above t1

Upvotes: 2

Views: 4385

Answers (1)

Daniel Conde Marin
Daniel Conde Marin

Reputation: 7742

android:layout_above/layout_below are only allowed on RelativeLayout, use RelativeLayout instead of LinearLayout and it will work. Ex:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:id="@+id/below_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/rev_arrow">
    </LinearLayout>
    <LinearLayout>
        android:id="@+id/above_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />
</RelativeLayout>

Here's a good tutorial on layouts: http://android.programmerguru.com/android-relativelayout-example/

Upvotes: 2

Related Questions