Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using layout_above in a RelativeLayout

Tags:

Can someone explain to me why the ImageView is not appearing above the LinearLayout?

<RelativeLayout     android:layout_width="fill_parent"     android:layout_height="wrap_content">     <LinearLayout         android:id="@+id/rev_main"         android:layout_width="fill_parent"         android:layout_height="wrap_content">         <!-- some stuff in here -->     </LinearLayout>     <ImageView         android:id="@+id/rev_arrow"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:src="@drawable/arrow"         android:layout_above="@id/rev_main"         /> </RelativeLayout> 

I don't get it.

like image 790
Andrew Avatar asked May 11 '11 21:05

Andrew


1 Answers

This happens when you specify alignment relative to another layout. The solution I found was to go the other direction.

Instead of telling the ImageView to be above the LinearLayout, tell the LinearLayout to be below the ImageView.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="wrap_content">     <LinearLayout         android:id="@+id/rev_main"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_below="@+id/rev_arrow">         <!-- some stuff in here -->     </LinearLayout>     <ImageView         android:id="@+id/rev_arrow"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:src="@drawable/arrow"         /> </RelativeLayout> 
like image 91
Error 454 Avatar answered Oct 01 '22 05:10

Error 454