Android的 - 对侧翻的ImageButton的不同的图像 [英] Android - different image for rollover on ImageButton

查看:125
本文介绍了Android的 - 对侧翻的ImageButton的不同的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在用户的焦点涉及到的ImageButton指定不同的形象呢?我想,当用户的关注来自于按钮或显示在LinearLayout中的图像按钮,更改图像,当用户presses按钮。

Is it possible to specify a different image when the user's focus comes to an ImageButton? I want to display an image button on a LinearLayout and change the image when the user's focus comes on the button or when the user presses the button.

感谢。

推荐答案

是的,你可以做到这一点。你需要的是一个定义选择可拉伸的XML文件。

Yes, you can do this. What you need is a drawable xml file that defines a selector.


<selector xmlns:android...
  <item android:state_enabled="false" android:state_focused="true" android:drawable="..." />
  <item android:state_enabled="true" android:state_focused="false" android:drawable="..." />
</selector>

然后,使用绘制XML的ID在你的布局XML指定的ImageButton时。

Then, use the id of this drawable XML when specifying the ImageButton in your layout XML.

这篇关于Android的 - 对侧翻的ImageButton的不同的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆