Theme.Holo.Dialog text is unreadable - android

I have an Activity containing a single EditText and a Button that uses a custom style, derived from Theme.Holo.Dialog. The Activity is defined as:
<activity
android:name=".activity.MyActivity"
android:label="#string/activity_myactivity"
android:theme="#style/Dialog">
The style Dialog is defined as:
<style name="Dialog" parent="#android:style/Theme.Holo.Dialog">
</style>
However, when the activity is launched, the text in the EditText is black on a black background, making it unreadable. I can change this in the above style definition by adding <item name="android:textColor">#color/white</item>, but I feel like I must be doing something wrong, as the pre 3.x Theme.Dialog seemed to have the text color, etc already defined. (I would use that but am unhappy with the inconsistency with the dialog with the rest of my app that is using the Holo theme)

Update : I tried your code on ICS seems to work fine..

Set android:setInverseBackgroundForced="true" on your activity

Related

How can I style the title of the Spinner dialog by xml?

In my current implementation, I have modified the whole style of my application...
I successfully modified the Spinner style, so I was able to change the RadioButton look and feel:
I am now working on the title, but seems really hard to style.
I would like to change, for instance the title text color (and optionally removing the triangle)
I know I could do that by extending Spinner or Dialog, but I have to do achieve that by playing with xml.
Here is my current code that succesfully modified other dialog properties:
<style name="Theme.HoloEverywhereDark.Sherlock" parent="Theme.Sherlock">
<item name="android:spinnerStyle">#style/SpinnerDark</item>
<item name="android:spinnerItemStyle">#style/SpinnerItemDark</item>
<item name="android:spinnerDropDownItemStyle">#style/DropDownItemDark</item>
</style>
To change the triangle, you could use the second answer here: How to create android spinner without down triangle on the right side of the widget
I haven't yet figured out how to style the main text, but you may just be able to apply normal text field formatting to it via the Spinner in xml (textColor, etc).

Android Styling/Theming of just Search Dialog

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.

Styling all TextViews(or custom view) without adding the style attribute to every TextView

Is there a way to format all TextViews, Buttons or whatever with a theme ?
Like in CSS when i want to format all a-tags
a{
/some css here/
}
I want to do that in android via xml when I'm applying a theme to my application.
Any ideas ?Thanks
http://bartinger.at/
Update 1.0:
I want to create a theme that formats the text in all TextViews green and in all EditTexts red. So that i just apply the theme and I never have to worry about the style attribute!
Update 1.1:
So I found some that piece of code and I think that's a good beginning
<item name="android:textViewStyle">#style/MyTextView</item>
<item name="android:buttonStyle">#style/MyButton</item>
I think thats the answer to my question. But I have another one. I want to write my own ActionBar and wanted to know how I can apply a default style or default attributes (again without adding the style attribute in the layout xml :P )
I have a class
public class ActionBar extends LinearLayout{ }
and I'm gonna use it like that in my application
<at.bartinger.uil.ActionBar>....</at.bartinger.uil.ActionBar>
The ActionBar should have some default attributes (like height and width) and then adding some custom style attributes which could change from app to app (like background)
yes you can you can apply a theme to the whole application and then all your textviews will have that style.
Inside the styles.xml file you have to define your CustomTheme
for example:
<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>
you add something like text
"android:textStyle="myStyle" and specify the details in Mystyle
You can apply a style read more here.
for the action abr you should look here http://developer.android.com/guide/topics/ui/actionbar.html
especially at the bottom it explains very well how to style the bar

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>

Text color doesn't change in an AlertDialog when applying an app wide theme

(Note: build minimum and target API 7)
Ok, here is a real stumper for this newbie between the chair and the keyboard:
I am applying a them to my app, and using AlertDialog for some key information at a few key places (i.e. a EULA pop up on first app run). My problem is this, everything is fine until I apply a theme (or style to the Activity). My text everywhere but the pop ups formats correctly. The problem is that I am changing from the default white text on black back ground to black text on white background. The background changes on the pop ups but not the text, so the net effect is that I have a white pop up with the text there (scroll bars show for the long winded EULA) but the text is unreadable because it is the exact same color as the background.
Here is the my_style.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="main">
<item name="android:background">#FFFFFF</item>
<item name="android:textColor">#000000</item>
<item name="android:typeface">sans</item>
</style>
</resources>
I know I am implementing the call correctly because everything else in the app formats correctly, what am I missing? The app works just fine when the android:theme="#style/main" is removed from the <application> tag in the manifest file (formating removed from the entire app and the dialogs are readable). Thanks for getting a newbie set straight.
Have you passed the theme to AlertDialog's or AlertDialog.Builder's constructor when creating the dialog?
See here.

Categories

Resources