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.
Related
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.
If I put a TextView in a custom dialog box, the text will be black by default.
Unfortunately, the support fragment dialogs backgrounds are dark gray. Black on gray is very hard to read.
I could change the TextView to white or something like android:textColor="?android:attr/textColorPrimaryInverseDisableOnly".
But the dialog boxes on the new android (Holo Light) are white. So it will be white on white.
I could use a hack like forcing it to be white on old versions of Android and forcing it to be black on newer versions of Android, but I'd rather find a more elegant solution.
Is there a way to change the TextView to imitate the same text that's normally put on the support DialogFragment? I'm using Action Bar Sherlock, if that matters.
Try this
alertDialogBuilder.setInverseBackgroundForced( true )
works fine in my case on pre-Honeycomb devices and newer ones. The title still appears in a darker color but the main text is clearly readable on all devices.
If you're using ActionBarSherlock, I'm guessing you're supporting old devices as well. Sad thing about it is that old phones won't display any Holo Dialog, only old ugly Dialogs (and on many phones, they'll also be heavily customized by manufacturer). Therefore can't assume your Dialog will be Light.
There's only 2 things you can do :
Leave it as is and let the system handle the style of your Dialog
Set a custom view to your Dialog. Check here :
DialogFragment : Using AlertDialog with custom layout
I am developing an Android application where I have set the following theme to one of my activities so that I have a nice translucent background.
android:theme="#android:style/Theme.Translucent.NoTitleBar"
This works pretty well with versions before 14 (ICS), but on ICS, although the activity is shown with translucent background, all the elements inside the activity start using Gingerbread theme. i.e. the buttons inside the activity are displayed with yellow highlight when selected instead of blue on ICS. Similarly, a spinner button when activated/clicked display the items as dialog instead of ICS popup/popdown style.
Can anyone please help me on how to get the translucent background along with the ICS theme?
To have the blue highlight from ICS and up you need to use a Holo theme, all other themes will render components as if they are being displayed on Gingerbread and below because that is how the theme is telling the system to render them.
You could extend the Holo theme of your choice and use the members from the translucent theme which will give you your desired effect on ICS and above.
The theme data is available in <android-sdk>/platforms/android-<API-level>/data/res/
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
I would like to modify the background of the title bar of the dropdown dialog associated to a spinner.
If this is not possible I would like to know what resource is used to draw this background android.R.drawable.* ?
This is an effort of uniformity for my various pop ups in my application.
You can change everything using styles and themes.
Take a look at this example for buttons:
http://blog.androgames.net/40/custom-button-style-and-theme/