Zeeno
Zeeno

Reputation: 2721

How do I set the position of an image view in a relative layout in Android?

I'm trying to position an image below a TextView in a RelativeLayout but it doesn't work. when i set its position using android:layout_below. This is my xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="#ccc"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TextView 
android:id="@+id/app_details_1" 
android:text="@string/app_details_1" 
android:textColor="#347"
android:gravity="center"
android:textSize="9pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>  

<ImageView 
android:id="@+id/logo"
android:src="@drawable/secs"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@+id/appdetails_1" <!-- I'm setting it here -->
/>

</RelativeLayout>

Instead it just places the image at the top left of the screen. How do I position it? Is layout_below a wrong positioning code?

Upvotes: 0

Views: 1713

Answers (2)

codeScriber
codeScriber

Reputation: 4612

it should be ok, but first try to make sure the textView is positioned on top by using layout_alignParentTop="true" for the textView and see if it does the trick.

Upvotes: 0

Michael
Michael

Reputation: 54705

There's a mistake in your xml. Must be

android:layout_below="@id/app_details_1"

Upvotes: 4

Related Questions