我想将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评论? –