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
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 have a multichoice ListView whose items have a light (transparent) background by default and a dark one while selected. Therefore, I would like to have the TextViews in the items change their color accordingly, i.e. black by default and white while selected.
Obviously, I can manually define a selector that does this, but is there some predefined color or style in the Android SDK that I could use out of the box?
Just for illustration, the navigation drawer in Gmail does this:
How can I change the background color of a ListView Item in Firemonkey (Delphi Android)?
The Listview itself can be set to transparent, but if I add an Item it has white background/
I Think you'll need to do this in the style designer
Right Click on the TListView control and select "Edit Custom Style". In the Style "Structure" Treeview select the itembackground property and set the color to Null.
Remember to select the newly created ListViewStyle in the TListView's property inspector StyleLookup parameter
Maybe you can try to add a TImage component as the background of your items. Then load a bitmap in it with the correct size and color.
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 change the background color of spinner and customize spinner. When I used this code in xml android:background="#000000" the color changed but the arrow on the spinner disappears. How can I cuztomize spinner and change the background color without disappearing the arrow?
The arrow is black (or close to it) by default, so it won't show up on a black background. You can change the arrow with the android:dropDownSelector attribute in your XML.
The "background" attribute on a spinner refers to a drawable which contains the background color and the arrow. By specifying a color for the background, there is no longer any arrow. To fix this you need to provide a new 9 patch drawable with the arrow in it.