开发者

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?


There's a mistake in your xml. Must be

android:layout_below="@id/app_details_1"


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜