如何禁用默认按钮的颜色变化上单击属性 [英] How to disable the default Button color changing property on onClick
问题描述
有关默认的Android按钮,当我点击它,它的颜色变为橙色几秒钟(通知按钮被点击的用户)。反正,我不希望这个属性。我不想改变我的按钮颜色。如何禁用此属性?
For the default android button, when I click on it, its color is changed to orange for a few seconds (for notifying the user the button is clicked). Anyway, I don't want this property. I don't want to change my button color. How can I disable this property?
推荐答案
有一看<一href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob_plain;f=core/res/res/drawable/btn_default.xml;hb=HEAD">how按钮的样式通过Android的:
Have a look on how button is styled by Android:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
android:drawable="@drawable/btn_default_normal" />
<item android:state_window_focused="false" android:state_enabled="false"
android:drawable="@drawable/btn_default_normal_disable" />
<item android:state_pressed="true"
android:drawable="@drawable/btn_default_pressed" />
<item android:state_focused="true" android:state_enabled="true"
android:drawable="@drawable/btn_default_selected" />
<item android:state_enabled="true"
android:drawable="@drawable/btn_default_normal" />
<item android:state_focused="true"
android:drawable="@drawable/btn_default_normal_disable_focused" />
<item
android:drawable="@drawable/btn_default_normal_disable" />
</selector>
要样式化按钮,Android的主题图片资源,只是通过复制Android的之一,并更换所有 @绘制/ btn_default _ *
按 @android:绘制/ btn_default_normal
在项目
•变量(和只是删除项目
取值你不想要的)。例如:
To style your button with Android's themes images resources, just create your own selector by copying the Android's one and replace all @drawable/btn_default_*
by @android:drawable/btn_default_normal
in item
s tag (and just remove item
s you don't want). For example :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"
android:drawable="@android:drawable/btn_default_normal" />
</selector>
然后,将此绘制选择为机器人:背景的按钮
希望它帮助。
(如果你愿意,我也可以提供一个例子将这种背景下很容易地给所有的按钮,就问我。)
(If you want, I can also provide an example of applying this background easily to all your buttons, just ask.)
这篇关于如何禁用默认按钮的颜色变化上单击属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!