机器人的EditText融合到背景机器人、背景、EditText

2023-09-04 05:18:34 作者:如若回到当初

我的应用程序使用 Theme.Holo.Light.DarkActionBar 作为父主题。

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

当我用我的Andr​​oid 3.2平板电脑模拟器中,形状的EditText几乎是不可能看到的。它看起来像它试图绘制白色白色。在这里看到:

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:

当我使用它在我的Andr​​oid 4.0平板电脑模拟器中,EditText上造型看上去就好了。你可以看到沿的EditText底部的深灰色线条。如果你在上面的图片,你会勉强看到一条白线在同一个地方,因为它穿越浅灰色的背景水印。

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.

下面是我在布局的EditText:

Here is my EditText in the layout:

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

和这里的风格:

<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>

为什么我得到的EditText画的颜色不对?我不是重写绘图code或背景的绘制。

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

推荐答案

其他答案是没有真正解决我的问题,我从来没有想通了什么是真正造成问题。但是,这是我如何解决它:我的解决方法是复制.9.pngs和造型的小部件的EditText从冰淇淋三明治和硬coded到我的应用程序的蜂窝和冰淇淋三明治。

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.

编辑:

我创建了一个文件名为res /绘制-nodpi / edit_text_holo_light.xml与以下内容:

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>

然后我在styles.xml创建了一个样式来设置:

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

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

然后我从Android SDK中复制的.9.png文件,并把它们放在RES / drawable- *。文件名中列出了上述的xml

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.