简体   繁体   English

Android,仅更改按钮的单击颜色

[英]Android, change only clicked color of a button

I would like to change the default orange color that appears when someone press an Android button. 我想更改有人按下Android按钮时出现的默认橙色。 I have done many searches but all I found was the use of selectors . 我进行了很多搜索,但发现的全部是selectors的使用。 I understand the principle, but I don't want to modify the grey aspect of the normal button (not pressed). 我了解原理,但是我不想修改普通按钮(未按下)的灰色外观。 But using selectors force to define all characteristics of all aspects (pressed or not). 但是使用selectors强制定义各个方面的所有特征(是否按下)。

I don't know how to obtain the default aspect of buttons in the light theme, so can anyone tell me where I can find the original parameters of the light theme or at least give me another means to simply change the color of the button when clicked? 我不知道如何在灯光主题中获取按钮的默认外观,所以谁能告诉我在哪里可以找到灯光theme的原始参数,或者至少可以给我另一种方法来在灯光theme时简单地更改按钮的颜色点击了吗?

You can copy the Android's selector into your project, the one that Android sets it by default to buttons, and modify only the state when the button is pressed by just changing one single drawable. 您可以将Android的选择器复制到您的项目中,该选择器将Android默认情况下将其设置为按钮,并且只需更改一个可绘制对象即可仅在按下按钮时修改状态。

You could find the file in \\android-sdk\\platforms\\android-10\\data\\res\\drawable\\btn_default.xml 您可以在\\android-sdk\\platforms\\android-10\\data\\res\\drawable\\btn_default.xml找到该文件

Sorry bro........... i guess only selector will help you...... You must go with selector..... and selector are reusable xmls you can use in all buttons.....:) You can refer below link. 抱歉,兄弟...........我想只有选择器才能帮到您...您必须使用选择器.....并且选择器是可重用的xmls,您可以在所有按钮中使用... .. :)您可以参考下面的链接。 :) http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList :) http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM