I have multiples CheckBox.
I've set a selector for normal and pressed states.
In my app I'll have a dynamic color and i want change the color according to the user's selection, there is a way to change the color for a CheckBox?
You can change CheckBoxs drawable using android:button="#drawable/your_check_drawable" attribute.
Related
I'm using Material 3 ButtonToggleGroup, I want to have a different background when a button is selected. However, If I don't add any attributes to my style applied to MaterialButton, I get the background set to colorPrimary when a button is selected but when it's not it's transparent.
When I add a backgroundTint attribute, it always has the same background color, no matter if the button is selected.
I want to programmatically create theme and set it to my Edittext. (I need to set colorControlNormal and colorControlActivated properties). So I guess I need somehow create theme in my code, give those 2 properties to it and than apply it to my Edittext.
Also I need to programatically give button the drawable background. But I need programmatically set color to this drawable stroke.
How can I achieve this in code?
Is there a way to read current theme colors from code ?
I want to
1. Read disabled Button color and put it as EditText background
2. Read Spinner selected item color and put it as TextView background
Read disabled Button color and put it as EditText background
Disabled is not a color. It is a state of a StateListDrawable that is used for the button background. Hence, you cannot "read disabled Button color", because there is no simple color for "disabled".
Read Spinner selected item color and put it as TextView background
The selected item in a Spinner has no specific color, as so therefore I have no idea what color you might mean here.
I want to implement the below:
A spinner which would have a custom layout, its background color would be black and font would be white. But what I want is that when I select any component then my selection background and font color should reverted back to its defaults (in terms of color).
#Rao use custom Spinner and for colour state change use Color State list
In my android application, I use a listview and some linear layout on wich the user can click.
Of course, I had to set the background of my LinearLayout to a xml file where the stated pressed, selected are defined:
myView.setBackgroundDrawable(
getDrawable(android.R.drawable.list_selector_background));
So no problem I set the drawable to transparent when normal use and orange when clicked.
My only problem is that on the galaxy S and some other customized phone (Sense UI) the color of the listview clicked is blue or green!
So I need to pick this color to set it to the background of my linearlayout.
I don't want to mix orange and blue, or orange and green for my user!
Where can I get this color???
That woule be really helpfull!
Just found the answer:
android:background="#android:drawable/list_selector_background"