我正在使用新的android應用程序。現在我需要在右下角放置一個徽標,這裏我使用相對佈局作爲父級。所以對我來說很難,請有人幫我解決這個問題。 圖片 需要在相對佈局中適合徽標
回答
使用此
<?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>
您也應該在ImageView中使用layout_alignParentBottom屬性,因爲視圖默認位於相對佈局的左上角。 – Daniel 2013-05-10 04:18:18
這一個作品非常感謝你 – 2013-05-10 04:19:36
@丹尼爾:在這種情況下,沒有必要。它從'@ + id/progressBar'繼承該屬性。 – 2013-05-10 04:20:29
你可以很容易地通過使用像這樣做:
.....
<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"
/>
但它示出了像\t錯誤 - [輔助功能]使圖像缺少contentDescription屬性 \t - 錯誤:未發現在包「機器人」屬性「alignParentBottom」資源標識符 \t - 錯誤:未發現屬性「alignParentRight」資源標識符in'android' – 2013-05-10 04:17:27
我編輯了我的答案,改爲使用layout_alignParentBottom和layout_alignParentRight。缺少的內容描述僅僅是lint的警告。 – Daniel 2013-05-10 04:20:23
- 1. 在相對佈局中創建佈局
- 2. 是否需要在一個.xml文件中使用多個佈局(線性佈局,相對佈局)
- 3. 如何在相對佈局中動態添加相對佈局
- 4. 3列布局需要高度相等
- 5. ScrollView不適用於相對佈局
- 6. 對準的主要相對佈局
- 7. 在流線佈局中集中徽標並限制徽標的最大尺寸
- 8. Android:相對佈局佈局
- 9. 的Java佈局適合我的佈局
- 10. 如何讓我的Android Gallery適合我的相對佈局?
- 11. 對齊在相對佈局
- 12. 的ListView在下面和上面的一些佈局相對佈局不適合在對話框
- 13. 相對佈局中的表格佈局
- 14. 相對佈局中的佈局權重
- 15. 相對佈局
- 16. 相對佈局
- 17. 在相對佈局內佈局TextView的問題(在主佈局相對佈局中)
- 18. 需要編輯相對佈局的幫助
- 19. 多次組合3個相對佈局
- 20. 佈局不適合屏幕
- 21. 佈局不合適Screensize
- 22. extjs面板適合佈局
- 23. 在對話框中的相對佈局的Android佈局
- 24. 在相對佈局中對佈局的權利分配 - android,
- 25. Android中的相對佈局
- 26. 編程中相對佈局
- 27. 重疊在相對佈局
- 28. ListView在相對佈局
- 29. 如何在相對佈局
- 30. 相對佈局positionnement
檢查答案正確如果確實幫助你,以幫助他人解決同樣的問題。 – Daniel 2013-05-10 04:15:44