Change colour of activated list item background on Honeycomb - android

For Honeycomb, I have set my listview items to use the ?android:attr/activatedBackgroundIndicator style so they remain highlighted when selected.
How do I change the colour of the highlight?

Define a custom theme with the item:
<item name="android:activatedBackgroundIndicator">#drawable/my_background</item>
Next, declare that drawable in a state list .xml file under res/drawable/my_background.xml as illustrated here: http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList Make sure that it has an item that responds to android:state_activated="true". This is your activated highlight.
The theme step is optional, (you could use the state list drawable directly if you choose,) but it gives an added layer of flexibility and since you've already defined your ListView items to use that theme attribute you can make this change in one place to affect any Activity that uses the custom theme.
If you need more info on themes look here: http://developer.android.com/guide/topics/ui/themes.html

Related

Theme from Palette

I'm making an app that retrieve a lot of images from some server. I'm tinting each item in my List using Palette library. When a choose one I open another activity to show details of this item.
I want to build a theme based on the selected theme to apply in detail activity.
Is there a way to programmatically build a theme based on a Palette from a Bitmap?
If it is about the color of material design, there is a solution.
Remember: You cannot change the modify those colors at runtime but you can switch between themes at activity start.
When an user select a color, apply corresponding style and restart activity. Otherwise, change some other colors like Google keep
To set theme .
super.onCreate(savedInstanceState);
setTheme(...style.YourTheme);
To restart activity: Call the recreate() method of the activity.

How to set Android action bar menu item background dynamically?

I have a use case where I need to create menu items and sub menus dynamically in onPrepareOptionsMenu and set those item's and sub menu's background colors dynamically.
The background colors are determined at runtime. There isn't a pre-existing list of background colors I can put in XML (you can basically consider them to be RGB values typed into a text view in the same activity as the menu).
I only want to change the menu item's backgrounds if they are shown in popups (i.e. SHOW_AS_ACTION_NEVER or SHOW_AS_ACTION_IF_ROOM when there is not enough room), not when they are shown directly in the action bar.
I know I can use a custom view inflater to change the background as the menu item views are inflated, but that requires reflection and depends on the View subclass's name. That name might be different on different versions of Android or for different manufacturer's devices.
Is there a way to do this without depending on anything OS version- and device-specific?

Change the down state color of the Android ActionBar UP/Home button

I'm using ABS, and I basically just want to know if there is any property that will let me overide the default blue I'm getting in a button down. My application is all red, and it's a small detail that's killin me. Ideas?
The actionBarItemBackground theme attribute will allow you to change the action item selector.
If you're using it with ActionBarSherlock be sure to provide an entry with and without the android: prefix.

Android, 3.0+ spinner dialog style

I am trying to change the drawable used as background in the spinner dialog. Prior 3.0 it works fine, I just change the AlertDialog style to use my images, but that does not work when the activity is inheriting from a Holo theme. I am trying to find which style I have to override but I simply cannot find which one is responsible for this.
I have tried inheriting from Theme.Holo.Dialog with no success.
Additionally, I am not able to completely override the selection selector drawable. Even when I supply my selector as background in the inherited #android:style/Widget.DropDownItem.Spinner, the device list selection is still visible under my selector.

Android: selector for highlighting menu items?

while I'm able to set "highlight color" for ListView items using android:listSelector
attribute and appropriate selector, I'm unable to do the same, or something similar,
for Menu items - they just keep using default system color scheme. I've read Creating Menus article and found nothing there. Any clues?
Btw: I'm referring to Menu accessible via 'Menu' button.

Categories

Resources