Is there a way of changing the color of the Spinner control?
For example, Android 6 will render text with an arrow. I need to change the color of that arrow.
The change should apply to any version of android.
For example, Android 4 has underline with corner triangle. I have seen some approaches where you replace the icon that is being drawn, but that solution would not work for me. I need to change the color of the default icon.
Update
I have found how to apply style on Android Spinner using styles.xml,
<item name="android:spinnerStyle">#style/SpinnerItem</item>
but I cannot find what is the correct style to apply for the icon color to change.
It turns out, there is no nice way of doing this. It is possible to change the images used for the spinner, but then I would need to provide different set of images for each version, and also have conditionals / logic on the android code, to specify which set should be used based on version.
Related
Is there a way to change the ripple colour of a control programmatically? Specifically, i want to be able to fetch the theme colours from an API and apply them to the whole application. From several answers around, i have learned that android doesn't allow to change the theme dynamically, so I set to implement my own theming.
One thing remains to be changed, the ripple colour:
Is there a way to change this dynamically (programatically) for
a single control?
EDIT: Specifically, I want to apply this to MenuItems inside a NavigationView and children clickable RelativeLayouts views of a ListView.
Is there a reasonable way to do it for the whole application? Like a rough equivalent of changing colorControlHighlight ?
With a MaterialButton you can use:
button.setRippleColor(ContextCompat.getColorStateList(this,R.color.selector));
Okay... I tried asking this before, but I dont think I explained it well...
I have a button in Android. The button's default color is #999999 (Holo Light), with it's opacity (I think its 40%), on my background color, it ends up calculating to #575757. The background is #303030.
I would like to apply a BackgroundTint to this button. The color I am applying as the tint is #F68800. However, when I apply this tint, the color of the button does not show as #F68800, it instead calculates to #7c501a. I assume this has to do with the Holo Light button being slightly transparent...
What can I do to get the button's final color to show up as #F68800?
I have tried using android:backgroundTintMode="src_over", but that ends up ignoring the style of the button and the 9 patch.
As you suspect, the original alpha is your problem. You need it to be ignored in order to get your "clear" tint color. However, ignoring the original alpha also means that you lose the shape/style that the button gets from its 9-patch (as you've already noticed).
Naturally, this makes for an impossible situation -- you cannot both ignore and use the original alpha.
If this is really important, I think your best bet may be to just copy the original 9-patch into your project (don't forget all the dpi variants and various states), make the main button area an opaque white, and make your tinted buttons use that background instead.
The easier alternative is to switch to the Material themes (perhaps the support library version in order to get backwards compatibility). The support library also enables backgroundTint on older Android versions.
Is there a way, to get the button-clicked colour based on the current theme? The best would be a xml #color that I can use.
I am planning to use this colour for my ImageButtons when pressed.
If you just want to get a specific color one time, you could hold the button down on your device and screenshot it. Then open the image in MS Paint or something to grab the colors used.
I have found an workaround. When you set this as background, the colour is changed automatically by the operating system according to the theme as if it was a button.
android:background="?android:attr/selectableItemBackground"
If you want to use the attribute on pre API 11 devices you can use:
android:background="?attr/selectableItemBackground"
I want to change the color of the bottomline of the sherlock actionbar.
But I want to change it dynamically.
When the user is offline I want it to appear red, when he is logging on I want it orange and when he is succesfully connected the line should be green.
How can I achieve this?
Thanks.
I found a solution in case anyone wants to do this.
I used this website to make 3 styles and took the 'ab_transparent' resource out of the zip.
To set the actionbar on runtime I used
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_transparent_connecting));
Sidenote: this worked perfectly on android 4.0+ but on <4.0 I had to call
this.supportInvalidateOptionsMenu();
after setting the backgrounddrawable for it to take effect.
I have a text field, and on Android 2.2, when it is in focus or being used, it highlights it and puts an orange boarder around it.
The orange really doesn't look good with the other colors in my app, so I am wondering if there is any way to change that to a different color...
Thanks in advance.
You can write selectors for your textview using which you can change the appearance of your textview when it is selected.
You can refer to this:
http://developer.android.com/reference/android/content/res/ColorStateList.html