我想將ImageView
放在ImageButton
的後面。要做到這一點,最好的方法是什麼?如何將一個物品放在android的另一個物品後面?
0
A
回答
3
我相信最簡單的方法是將ImageView
和ImageButton
都包裝在FrameLayout
中。例如:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/your_image" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" />
</FrameLayout>
1
您可以在某些佈局中重疊視圖(例如FrameLayout
,RelativeLayout
)。
只需在xml佈局中放置兩個視圖,以便重疊(例如對於FrameLayout
,寬度和高度均爲match_parent
)。最後一個添加到頂部。
0
最簡單的方法是隻使用ImageButton
。
ImageButton
具有用於背景圖像
和src
屬性用於在前景圖像一個background
屬性。
在StackOverflow上查看此存在example。
<ImageButton
android:id="@+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/album_icon"
android:background="@drawable/round_button" />
0
或者您可以使用一個RelativeLayout
像matiash說:
下面是一個自定義標題含有個人資料的Facebook圖片抽屜式導航的示例代碼
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:facebook="http://schemas.android.com/apk/res-auto"
android:id="@+id/customHeader"
android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/green_gradient"/>
<com.facebook.widget.ProfilePictureView
android:id="@+id/leftPic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
facebook:preset_size="small"
android:paddingBottom="4dp"
android:paddingLeft="3dp"
/>
</RelativeLayout>
結果
您可以添加ImageButton的,你想,只需添加以下代碼到你的佈局
<ImageButton
android:id="@+id/myImageButton
android:layout_width="SET YOUR WIDTH"
android:layout_height="SET YOUR HEIGHT"
android:background="ADD YOUR BACKGROUND" />
相關問題
- 1. 如何從1000個物品中隨機選擇一個物品?
- 2. 對另一個物品進行排序
- 3. 在Magento中使用一種物品作爲多個物品
- 4. RxJava一個接一個發射物品
- 5. 如何在剩餘物品之後選擇一個物品應在循環機視圖中自動選擇android
- 6. Android Studio:列出物品(物品)
- 7. 從一套物品到另一套物品的R流程中的可視化
- 8. 如何從一組物品中選擇特定物品?
- 9. 掉落物品如果超過1個物品存在
- 10. 如何動態地居中一個div裏面的物品
- 11. 如何更改另一個網格物品的背景,同時點擊在android
- 12. 如何將等價物品組合在一個Python列表中?
- 13. 瞭解一個基本的物品
- 14. 找到一個沒有ID的物品
- 15. jQuery UI可排序。阻止一個特定物品掉入另一個特定物品?
- 16. 如何將物品拼合成物業?
- 17. 產品作爲一批物品(但物品都是一樣的)和solidus_product_assembly
- 18. 在Magento中,我如何將物品運輸成本放在產品頁面上?
- 19. 將收藏中的所有物品與另一個收藏中的物品進行比較?
- 20. 如何將物品點擊事件添加到物品控件
- 21. 如何將Fogbugz物品出口到TFS 2012工作物品?
- 22. 將彈性物品堆疊在一起
- 23. 陣營:存放物品的購物車有唯一的ID
- 24. UIStackView去野外堆放物品,在一個地方
- 25. 如何在物品尚未創建時設置物品的ID ..?
- 26. 如果物品存在於數組中,如何拼接物品?
- 27. 如何找出我已將物品放入哪個UL?
- 28. 獲取js物品的物品數量
- 29. 從不同的藏品中刪除另一個清單的物品清單
- 30. 購買物品後失敗(已擁有)消費該物品後
我能得到-1評論? –