Android spinner dropdown menu background color change - android

I want to change a spinner's dropdown menu background color without changing the background color of the spinner itself (it's transparent). Is it possible?

Yep, it's possible. Use android:popupBackground on the Spinner in your XML or setPopupBackgroundResource(int) in code.

To change the background color of the drop-down list, add android:colorBackground parameter to the theme in your styles.xml
Code:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:colorBackground">#ff0000</item>
</style>
Thus, the overall style is preserved: the effect when pressed, rounded corners, etc.
Screenshot:

When using Material Design 3 responsible attribute is:
<item name="colorSurface">#color/foo</item>

Related

Styling a Spinner, appcompat, material

So my app theme extends from AppCompat's Material Light theme with Dark Action Bar.
I applied an accent color.
Now I am trying to use a Spinner on a dark backround and because of the theme, the spinner has a dark gray arrow which changes to accent color when pressed.
How can I make this spinner's arrow white so that it is prominent on a dark background?
Here's the image of the Spinner:
If you want to apply same spinner style app wide, then in your values/styles.xml, override spinnerStyle with your custom style, which derives from an appcompat type and override android:background:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:spinnerStyle">#style/AppSpinner</item>
</style>
<style name="AppSpinner" parent="Widget.AppCompat.Spinner">
<item name="android:background">#drawable/your_spinner_background</item>
</style>
If you need a quick way to generate a spinner background, try android-holo-colors, choose Colored Spinner and supply your accent color.
So the support library 22.1 enables use of android:theme attribute on views. That should help here.
with android:background you can specify your own background resource. I find the arrow rather useless (tapping the spinner brings dropdown menu even without arrow) so if you don't want to draw a custom arrow image, just leave the background black or transparent.

Actionbarsherlock - Color of Textselection Buttons

In my TextView I enabled text-selection with android:textIsSelectable.
The problem is, that the appearing actionbar is white and the color of the buttons (copy , select, etc.) is white too. (I use actionbarsherlock 4.4.0)
Is there a possibility to change the color of these items in the styles.xml and if yes: What is the correct way?
Edit:
I found out that i can customize the ActionMode Tab using:
<style name="MyCustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionModeBackground">#color/color1</item>
<item name="android:actionModeSplitBackground">#color/color1</item>
</style>
But i am not able to change the color of the buttons

How to change AutoCompleteTextView border color of default theme in android?

I am using AutoCompleteTextView in my android application. I am using Theme.Light as my default theme for my application.
Here is how my AutoCompleteTextView look like
Now, I want to change the BLUE color border of that AutoCompleteTextView to some other color ,for different selection, keeping the border style as it as. I dont want full border. How to do that?
You can try like this..
see http://www.androidworks.com/changing-the-android-edittext-ui-widget for details
For other theme implementation go for this way
In your manifest in application
android:theme="#style/firsttheme"
IN res/values you can define theme.xml
<resources>
<style name="firsttheme" parent="#android:style/Theme" >
<item name="android:_DEFAULT_BASE_COLOR_1">#XXXXXX</item>
<item name="android:windowNoTitle">true</item>
... .
</style>
</resources>
For more info theme
You can use Holo Colors to tint it. It generates the 9-patchs and the styles.

theme - pressed color of TextView in ListView only

I'm trying to create an own theme which customizes all ListViews. I works perfectly fine for the selector but I want that the TextView color doesn't change to black when the ListView item is pressed (because the list selector is dark enough).
Here's what I tried. textColor in MyListView has no effect either. I also tried to define a drawable selector for textColor which uses white for all states, still no effect.
<style name="MyTheme" parent="Theme.Sherlock">
<item name="android:listViewStyle">#style/MyListView</item>
</style>
<style name="MyListView" parent="#style/ICSListView_Dark">
<item name="android:textViewStyle">#style/NoHighlightListTextView</item>
</style>
<style name="NoHighlightListTextView" parent="#android:style/Widget.TextView">
<item name="android:textColor">#android:color/white</item>
</style>
Is it event possible? It would be an big overhead to hack the color in code. I feel like there's still something I didn't understand. So...
How do I define a general theme for ListViews so the pressed color of the TextViews is white (instead black)?
Edit
After some reading I came to the conclusion that it is impossible to achieve that the way I describe. You can set textColor globally in MyTheme but then it affects all TextViews. Or you create an own list item layout which behaves the right way. But you can't modify the default android list item with a theme definition. That seems to be logical if I think about it again... A TextView should check if it is nested in a ListView otherwise and that will never happen.

Is it possible to make the Android options menu background non-translucent?

The options menu has a translucent background and I would like to make it solid and non-transparent. Is there a way?
Try this:
<style name="MyTheme" parent="android:Theme">
<item name="android:panelFullBackground">{your color or drawable}</item>
</style>
Also, see:
http://code.google.com/p/android/issues/detail?id=4441
How to change the background color of the options menu?
Completely overriding menu panel: Android MenuItem Toggle Button
set android:theme="myTheme", and define your own theme with whatever colours you want. Read up about Styles, and look at the android themes.xml.
Try this for android 4.0:
<style name="MyTheme" parent="#android:style/Theme.DeviceDefault">
<item name="android:popupMenuStyle">#style/MyPopupMenu</item>
</style>
<style name="MyPopupMenu" parent="#android:style/Widget.DeviceDefault.ListPopupWindow">
<item name="android:popupBackground">{your color or drawable}</item>
</style>
Also, the following site generate Action Bar Style :
http://jgilfelt.github.com/android-actionbarstylegenerator/
If you don't want to style a whole theme and just change the options menu background then set the panelFullBackground property to a DRAWABLE RESOURCE of your liking. Setting it to a color directly doesn't work so either make one coloured - 9patch, if you want to save in size -image and set it to that or make a couple and make a selector drawable with an image for each state.
I put my definition in a style that i use for all the activities in my project using:
#drawable/optionsmenu_back
optionsmenu_back being a 9patch image with a solid colour...

Categories

Resources