在android中将一张图像放在另一张图像上
我在 android 中有一个用户点击的 imageButton 。然后在他点击后,我希望在其顶部显示一个勾号或十字图像。 怎么可能呢?
<ImageButton android:layout_width="wrap_content"
android:text="Button" android:id="@+id/button1"
android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
android:background="@drawable/rhino" android:layout_marginRight="20dp"></ImageButton>
I have a imageButton in android which user clicks. Then after his click I want t0 show a tick or a cross image on the toip of it.
How is it possible?
<ImageButton android:layout_width="wrap_content"
android:text="Button" android:id="@+id/button1"
android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
android:background="@drawable/rhino" android:layout_marginRight="20dp"></ImageButton>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将 ImageButton 和刻度图像放入 FrameLayout 中,并使刻度图像的可见性“Invisible”。因此,当您单击 ImageButton 时,请将 Tick Image 的状态更改为 Visible。
put your ImageButton and the tick image in a FrameLayout and make the visbility of the Tick image "Invisible" . So when you click on the ImageButton then change the state of Tick Image to Visible.
获取对 ImageButton 的引用,然后使用其 setImage 方法之一,例如 setImageResource。
Get a reference to your ImageButton and then use one of its setImage methods, such as setImageResource.
您可以使用 ImageView 实现相同的效果。使用 ImageView
编写逻辑,在 onclick 事件中将两种类型的图像设置为 imageview
谢谢
迪帕克
You can achieve the same using ImageView. Use ImageView
write the logic to set both type of image to imageview in onclick event
Thanks
Deepak