Android Styling/Theming of just Search Dialog - android

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.

Related

Change spinner indicator drawable

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.

Designing Android Themes

Can anyone tell me how I can change my apps theme from the default ones made available? Holo and Holo.Light get a bit boring after a while.
The likes of Facebook, Google+, BBC Weather, Viber, Vine and Twitter all look very professional and have their own theme whereas the app I'm developing looks quite boring.
Is it possible to change the font of the text in my app? I know it's possible to change the colour and size of it.
Another thing which would be useful to know would be how to change the colour of the action bar that is used for my app. Currently it's black but I wouldn't mind changing it to a different colour than those used by the Android default themes (e.g. purple, green, blue, etc)
Maybe you can share some tips on what you think works well for Android design?
You can generate a custom theme at http://jgilfelt.github.io/android-actionbarstylegenerator/
If you only want to change a few font an colors etc take a closer look at this (source:http://developer.android.com/guide/topics/ui/themes.html)
If you like a theme, but want to tweak it, just add the theme as the parent of your custom theme. For example, you can modify the traditional light theme to use your own color like this:
<color name="custom_theme_color">#b0b0ff</color>
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowBackground">#color/custom_theme_color</item>
<item name="android:colorBackground">#color/custom_theme_color</item>
</style>
(Note that the color needs to supplied as a separate resource here because the android:windowBackground attribute only supports a reference to another resource; unlike android:colorBackground, it can not be given a color literal.)
Now use CustomTheme instead of Theme.Light inside the Android Manifest:
<activity android:theme="#style/CustomTheme">

Android XML Themes VS Styling

I've perused ALL of the questions here and countless tutorials on Styling and Themes for Android. The odd hierarchy between Themes and Styles is still a mystery to me.
My Manifest calls out this "Style" (android:theme, "#style/rforderstyle") [this is formatted from the manifest editor in Basic4Android] (not my choice but its what I have to use.).. however the manifest is still accessible should I need to.
I mention this because I've noticed that you can style a specific activity. I actually don't see a way to force have multiple "wigets" have their own "theme" while they all exist on the same activity.
Please advise if so then I my need to make my "little creations" as whatever "fragment" or "wigets".
What I'm attempting is a windows mobile app type form with a ton of User controls on it..so this set at the bottom happens to use a mid sized black text font.. but the control over here in the right upper is a different text size and color on & On & on ...
So regarding the style xml file, I've read that,,, its important that,,,, my parent be some all encompassing Android theme and I override individual "properties" in this section::
Could that mean that although I'm concerned with text size, since I have labels and editcontrols present the absence of a "parent" style that addresses these will cause me an error as I attempt to use this referenced parent style ??
How does a theme get into this mix...?
<resources>
<style name="rforderstyle" parent="#android:style/TextAppearance">>
<item name="android:textSize"> 21.0dp</item>
<item name="android:typeface">serif</item>
<item name="android:textColor">#FF9900 </item><!--#00FF00-->
</style>
</resources>
This is oddly confusing because the best examples reference layout files for the views but I don't really have layout files in Basic4Android I'm programmatically creating all of these views. If I don't need the depth of theme and style then fine but ...is the manifest supposed to point to a Style or a theme?

Android - Make a custom titlebar that uses the device's current titlebar theme

I'm trying to make a custom titlebar for my first Android application.
While I can find lots on the web about how to make them so you can change colours etc, I want my titlebar to look the same as the "standard" titlebar, but with a button that I can configure. This means copying the device's currently active themes to be able to style it in exactly the same way.
Not all devices simply use a gradient in the titlebar style, so adding a gradient (as suggested in other SO questions) doesn't really make sense.
Does anyone have any pointers how to read the style information?
try to extend an existing theme e.g.
create your own style which can ofcourse extend from existing from an existing theme. change the windowNoTitle to true.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="noTitleBarStyle" parent="android:Theme.Black">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#color/darkGrey</item>
<item name="android:colorForeground">#ff3333</item>
</style></resources>
or try to do it runtime as discussed here
Android - change custom title view at run time
I hope this helps.

Android preference title/summary text style

I have a couple custom preference items -- one that displays a swatch of the currently selected color, and another one that displays a thumbnail.
I have a custom layout for these that matches up very well, and have found that I can make the text appearance match by using android:textAppearance="?android:attr/textAppearanceLarge" as part of the TextView's xml. The problem is, while these generally look fine, they must not be the appearance the 'official' preferences use, since the colors end up wrong on some devices. In particular I'm porting my application to the Nook Color, and it uses a light grey background and black text color on the preference screen instead of black background/light grey text. My text color in this situation stays the same, but the rest of my layout is themed appropriately.
I'm really unsure what I'm supposed to do here to make my text match up with the 'official' theme. Should I be using obtainStyledAttributes and running though my layout to set things? The tutorials I've seen on using that so far have been really baffling, and it seems like there must be a textAppearance or style I can set in the XML to fix this.
You've to define your own application theme which inherits from the official theme you want. Actually, you can just define a theme MyTheme extending the Theme.Light for example.
Create an res/values/styles.xml file like that:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="#android:style/Theme.Light">
</style>
</resources>
Then, you just have to apply your theme using the android:theme attribute of the application entity of your AndroidManifest.xml:
<application android:theme="#style/MyTheme">
[...]
</application>

Categories

Resources