9

My app uses Theme.Holo.Light.DarkActionBar as the parent theme.

When I use my Android 3.2 tablet emulator, the EditText shape is almost impossible to see. It looks like it is trying to draw white on white. Seen here:

enter image description here

When I use it on my Android 4.0 tablet emulator, the EditText shape looks just fine. You can see the dark grey line along the bottom of the EditText. If you look in the above image, you'll just barely see a white line in the same place as it crosses the light grey background watermark.

enter image description here

Here is my EditText in the layout:

<EditText
    android:id="@+id/fieldName"
    style="@style/PlayerDetails.Field"
    android:capitalize="words" />

And here is the style:

<style name="PlayerDetails.Field">
    <item name="android:layout_weight">0.65</item>
    <item name="android:paddingLeft">10dp</item>
    <item name="android:layout_width">0dp</item>
    <item name="android:layout_height">fill_parent</item>
    <item name="android:layout_marginLeft">10dp</item>
</style>

Why is my EditText getting drawn the wrong color? I'm not overriding the drawing code or the background drawable.

Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
  • Hi Kenny Wyland, have you figure out your problem. I have also facing the same issue. – Asish AP Mar 31 '12 at 17:28
  • I never figured out the problem, but my workaround was to copy the .9.pngs and styling from Ice Cream Sandwich and hardcoded into my app for Honeycomb and Ice Cream Sandwich. – Kenny Wyland Apr 01 '12 at 17:17
  • see the below link http://stackoverflow.com/questions/9224560/how-to-change-the-border-colorun-focused-of-an-edittext?answertab=active#tab-top – DKV Sep 11 '13 at 10:04
  • http://stackoverflow.com/questions/9224560/how-to-change-the-border-colorun-focused-of-an-edittext?answertab=active#tab-top – DKV Sep 11 '13 at 10:06

3 Answers3

5

The other answers weren't actually solutions to my problem and I never figured out what was REALLY causing the issue. However, this is how I solved it: My workaround was to copy the .9.pngs and styling for the EditText widget from Ice Cream Sandwich and hardcoded into my app for Honeycomb and Ice Cream Sandwich.

EDIT:

I created a file called res/drawable-nodpi/edit_text_holo_light.xml with the following:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_multiline="true" android:state_window_focused="false" android:state_enabled="true"  android:drawable="@drawable/textfield_multiline_default_holo_light" />
    <item android:state_multiline="true" android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_multiline_disabled_holo_light" />
    <item android:state_multiline="true" android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_multiline_activated_holo_light" />
    <item android:state_multiline="true" android:state_enabled="true" android:state_activated="true" android:drawable="@drawable/textfield_multiline_focused_holo_light" />
    <item android:state_multiline="true" android:state_enabled="true" android:drawable="@drawable/textfield_multiline_default_holo_light" />
    <item android:state_multiline="true" android:state_focused="true" android:drawable="@drawable/textfield_multiline_disabled_focused_holo_light" />
    <item android:state_multiline="true" android:drawable="@drawable/textfield_multiline_disabled_holo_light" />

    <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/textfield_default_holo_light" />
    <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_disabled_holo_light" />
    <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_activated_holo_light" />
    <iten android:state_enabled="true" android:state_activated="true" android:drawable="@drawable/textfield_focused_holo_light" />
    <item android:state_enabled="true" android:drawable="@drawable/textfield_default_holo_light" />
    <item android:state_focused="true" android:drawable="@drawable/textfield_disabled_focused_holo_light" />
    <item android:drawable="@drawable/textfield_disabled_holo_light" />
</selector>

Then I created a style in my styles.xml to set:

<item name="android:background">@drawable/edit_text_holo_light</item>

Then I copied the .9.png files from the android sdk and put them in res/drawable-*. The filenames are listed in the above xml.

Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
  • Am experiencing the same problem, please give me more details on how you fixed this. – gath Jul 03 '12 at 05:10
  • 2
    I went into the android sdk folders to find the .9.png files which are used to draw the standard text fields. For example, one of them is called textfield_activated_holo_light.9.png. I copied all of those files into my res/drawable-v11 directory so they would be used for any Android version after and including v11. Then I added a drawable-nodpi/edit_text_holo_light.xml and in it I copied the style from the orignal Android styles. (It's too much to include here, I'll update my answer) – Kenny Wyland Jul 03 '12 at 22:51
1

You can have an action bar and still see the EditText light grey background watermark if you use themes like below:

AndroidManifest.xml

<activity
  android:name=".ClassName"
  android:label="ClassName"
  android:theme="@style/MyTheme" >

styles.xml

<resources>
  <style name="MyTheme" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
  </style>
  <style name="MyActionBar" parent="android:Widget.Holo.ActionBar">
    <item name="android:background">@color/black</item>
  </style>
</resources>

This works for the theme "android:Theme.Holo.Light" but not for the theme "android:Theme.Holo".

Etienne Lawlor
  • 6,817
  • 18
  • 77
  • 89
0

I figure out my issue. By setting theme in application element android:theme="@android:style/Theme" in manifest.xml file.

<application 

android:label="@string/app_name" 

android:icon="@drawable/logo" 

android:vmSafeMode="false" 

android:theme="@android:style/Theme">

Try this.

Asish AP
  • 4,421
  • 2
  • 28
  • 50
  • 2
    I'm using the standard android Theme.Holo, but it doesn't exist before 3.0 so I use the standard code provided by Google to switch between Theme and Theme.Holo based on OS version. The problem isn't that I'm not using a theme.. the problem is the Theme.Holo on Honeycomb isn't behaving properly on all devices. – Kenny Wyland Apr 03 '12 at 22:28
  • I have the same problem. I am testing my application on Motorola Xoom tablet. I've set Theme.Holo, but nothing changed (the EditText still blends into the background). Probably I would have to do some hardcoding also. – Sandra Apr 09 '12 at 11:11