悬停时按钮颜色更改 [英] Button color change on hover
本文介绍了悬停时按钮颜色更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是 Android 的初学者.我希望按钮在鼠标悬停时改变颜色.
我不知道如何在android中做到这一点.可以做到吗?
I'm just a beginner with Android. I want the button to change its color on mouseover.
I don't know how to do that in android. Can it be done?
查看按钮:
<Button
android:id="@+id/b8"
android:text="click me"
style="?android:attr/buttonStyleSmall"
android:textSize="20dp" />
推荐答案
您需要使用所谓的 selector
.
请记住,Android 中确实没有悬停"的概念,因为您无法将手指悬停在显示屏上.但是您可以创建选择器,例如,当按钮具有焦点时.通常一个按钮可以有三种状态:正常、聚焦和按下.
Keep in mind that there really isn't a concept in Android as "hover" since you can't hover your finger over the display. But you can create selectors for, say, when a button has focus. Normally a button can have three states: Normal, Focused and Pressed.
这篇关于悬停时按钮颜色更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文