我試圖在RelativeLayout
的TextView
以下定位圖像,但它不起作用。當我使用android:layout_below
設置其位置時。這是我的xml如何在Android中以相對佈局設置圖像視圖的位置?
<?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>
相反,它只是將圖像放在屏幕的左上角。我如何定位?是layout_below
錯誤的定位碼?
要完全解釋這個:'+ id'是這個id必須被創建的一個快捷方式。引用現有的ID時,它只是'id'。有關此官方文檔:http://developer.android.com/guide/topics/ui/declaring-layout.html#id – 2011-08-28 16:02:47
此外,錯字'appdetails_1'而不是'app_details_1' – Ronnie
@ user7777777777是的,這是唯一的錯誤。加號不是錯誤。 – Michael