iv tried several diffrent ways but cant seem to get the alertdialog to properly change themes. my activities have there custom theme set in the manifest so im not sure if this is causing the conflict.
im using :
AlertDialog alertDialog = new AlertDialog.Builder(new ContextThemeWrapper(this,R.style.DialogStyle)).create();
and im using the follwing style:
<style name="DialogStyle" parent="android:Theme" >
<item name="android:windowBackground">#drawable/background2</item>
<item name="android:textColor">#014076</item>
</style>
it only changes certain text colours. all the titles and messages are all still default white colours and the background doesnt change either.
any help please.
Prior to gingerbread, 2.3.X, you can't.
It explicitly sets the theme in the constructor of the dialog, but in gingerbread you can supply it.
Related
I modified my theme using the following style (part):
<item name="android:scrollbarTrackVertical">#drawable/scrollbar_1</item>
<item name="android:scrollbarThumbVertical">#drawable/scrollbar_2</item>
(plus of course drawable definition).
However it only works with activity. When activity opens dialog (DialogFragment), scrollbars are standard ones, not mine. Why?
Any help?
In 4.x devices, the drawable which indicates that this is a spinner and should be clicked is barely visible; it is using spinner_ab_default_holo_light.9.png. How can I make it use spinner_ab_default_holo_dark.9.png, or any other drawable of my choice?
The spinner is in a dialog. The app uses ActionbarSherlock 4.3.1 for Android 2.2.3 upwards compatibility. The app implements Android Action Bar Style Generator to create a Sherlock.Light.DarkActionBar theme. I am using a Values and a Values-v14 to manage the styles. This dialog attaches a specific style:
new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.FibroDialog))
which, in Values-v14, has a parent theme to make sure the dialog background is dark:
<style name="FibroDialog" parent="#android:style/Theme.Holo.Dialog">
</style>
Things I have tried:
In the theme generated by Android Action Bar Style Generator I added
<item name="android:spinnerItemStyle">#style/MySpinnerItemStyle</item>
and then added
<style name="MySpinnerItemStyle" parent="android:TextAppearance.Holo.Widget.TextView.SpinnerItem">
<item name="android:textColor">#FFF</item>
<item name="android:background">#drawable/spinner_background_ab_fibromapp</item>
</style>
which resulted in the drawable I actually want becoming the background of the item, not the spinner.
In the xml for the spinner, I tried
android:dropDownSelector="#drawable/spinner_ab_default_fibromapp"
which gives the same result as above, and
android:popupBackground="#drawable/spinner_ab_default_fibromapp"
which replaces the background of each spinner item with the drawable.
As a last resort, I made my own spinner_ab_default_holo_dark and spinner_ab_default_holo_light 9-patches; and they didn't show up at all.
How can I access that spinner drawable and change it to whatever graphic I want?
Although i'm new at this, i've also spent far too many hours looking for a similar answer. It seems the only solution is to create a style which is an exact copy of the system's spinner style and edit that which you which to change. It's troublesome, boring and not really practical, but if it must be done, it must be done... Due to time constraints, I ended up changing my layout a bit so that the standard spinner wouldn't look too bad.
I am attempting to style a DialogFragment and, despite extensive research within SO, developer.android and elsewhere, it's just not working right.
I am sure that I have applied everything correctly; in my DialogFragment onCreateDialog, I am putting:
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.FibroDialog));
and in values/styles.xml, I have:
<style name="FibroDialog" parent="#android:style/Theme.Dialog">
<item name="android:windowBackground">#drawable/panel_background</item>
</style>
and in values-v14/styles.xml, I have:
<style name="FibroDialog" parent="#android:style/Theme.Holo.Dialog">
<item name="android:windowBackground">#drawable/panel_background</item>
</style>
If I run that, I get the top row of dialogs in the image below, where nothing has changed at all, but I would expect the window to use my panel_background drawable. If I change windowBackground to background, I get the bottom row of dialogs in the image below, where it all goes wrong.
So how do I change this, so the entire dialogs have the purple background? I know I can use the layoutInflator and put a background colour in the layout, but that only does the middle bit.
I don't know if this is of any relevance, but the DialogFragment is launched from a SherlockFragment
tl;dr: White text style in app theme being picked up by search dialog, making search text invisible.
I'm struggling mightily with what seems like a trivial issue.
My app is using a dark background, and I've tweaked the text color to be brighter than the standard gray using #EEEEEE.
I've implemented a Search Dialog (pre-Honeycomb) and it works well, but the text in the search dialog picks up the same #EEEEEE so it is essentially invisible. Even the context menu displayed when I long press the search text picks up #EEEEEE, so the text there is invisible as well.
I'm tearing my hair out, and I'm running out of hair.
Style:
<style name="master" paret="#android:style/Theme.NoTitleBar">
<item name="android:textColor">#EEEEEE</item>
<item name="android:windowNoTitle">true</item>
</style>
Manifest:
<application android:icon="#drawable/icon"
android:label="#string/app_label"
android:theme="#style/master"
android:hardwareAccelerated="true"
android:debuggable="true">
The attribute android:textColor is not meant to be used inside theme styles, it is primarily useful in widget and text appearance styles.
If you want to change the general text colors through a theme, use instead the android:textColor* family of attributes. There are quite a few of them, and different Views use them differently, so it takes a bit of experimentation (or careful studying of the Android source code) to to get it all right. The android.R.attr documentation lists them all. Look for the attributes that begin with textColor....
To get you started, try this theme, it will behave better by not affecting the Search Dialog colors at all, which seems to be what you want. By the way, you don't need to set android:windowNoTitle to true in your theme as your parent theme does that already:
<style name="master" parent="#android:style/Theme.NoTitleBar">
<item name="android:textColorPrimary">#EEEEEE</item>
<item name="android:textColorSecondary">#EEEEEE</item>
<item name="android:textColorTertiary">#EEEEEE</item>
</style>
I got into the same problem as you. I've looked around for a solution but it seems that you just can't change the textColor of a dialog. My solution was creating a custom dialog based on this tutorial: http://blog.androgames.net/10/custom-android-dialog/
I extended this a lot based on the Android source code, always using the same method names etc to make it a bit easier.
It is not ideal, but as far as I know it's the best option...
EDIT: for your problem there might be a simpler solution: don't put the textColor into the theme, but put it in a style. I don't know how you're styling your app but I'm usually creating a "master-style" which all the others inherit from (direct or indirect). You could then put the textColor in there so all your standard dialogs will still have the standard textColor.
How to change a style from code?
I got a style used all across my app, for all buttons. If the user changes the skin of the app, the background of this style should change.
<style name="ActionBtn">
<item name="android:layout_width">#dimen/action_btn_width</item>
<item name="android:layout_height">#dimen/action_btn_height</item>
<item name="android:background">#drawable/btn_frame_bgstate</item>
<item name="android:padding">#dimen/action_btn_padding</item>
<item name="android:layout_margin">#dimen/action_btn_margin</item>
</style>
So far the only idea I got is to make a custom button that itself chooses its background on creation.
I have not found any good, generic way for skinning android apps yet, but if I could change styles from code, that would do the trick.
All suggestions welcome!
1) Create different themes for your skins.
2) Set those themes programatically using following code in your onCreate method.
setTheme(resid);
resid is the id of your theme.