简体   繁体   中英

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. I have done many searches but all I found was the use of 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).

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?

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.

You could find the file in \\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. :) http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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