2013-05-10 16 views

回答

2

使用此

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <ProgressBar 
     android:id="@+id/progressBar" 
     style="?android:attr/progressBarStyleHorizontal" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/progressBar" 
     android:layout_alignParentRight="true" 
     android:src="@drawable/ic_logo" /> 

</RelativeLayout> 
+0

您也應該在ImageView中使用layout_alignParentBottom屬性,因爲視圖默認位於相對佈局的左上角。 – Daniel 2013-05-10 04:18:18

+0

這一個作品非常感謝你 – 2013-05-10 04:19:36

+3

@丹尼爾:在這種情況下,沒有必要。它從'@ + id/progressBar'繼承該屬性。 – 2013-05-10 04:20:29

3

你可以很容易地通過使用像這樣做:

.....

<ImageView 
android:id = "@+id/logo" 
android:layout_width = "wrap_content" 
android:layout_height = "wrap_content" 
android:layout_alignParentBottom = "true" 
android:layout_alignParentRight = "true" 
android:src = "@drawable/logo" 
/> 
+0

但它示出了像\t錯誤 - [輔助功能]使圖像缺少contentDescription屬性 \t - 錯誤:未發現在包「機器人」屬性「alignParentBottom」資源標識符 \t - 錯誤:未發現屬性「alignParentRight」資源標識符in'android' – 2013-05-10 04:17:27

+0

我編輯了我的答案,改爲使用layout_alignParentBottom和layout_alignParentRight。缺少的內容描述僅僅是lint的警告。 – Daniel 2013-05-10 04:20:23