android编辑文本融入背景

android编辑文本融入背景,android,android-edittext,android-3.0-honeycomb,android-4.0-ice-cream-sandwich,Android,Android Edittext,Android 3.0 Honeycomb,Android 4.0 Ice Cream Sandwich,我的应用程序使用Theme.Holo.Light.darkaActionBar作为父主题 当我使用Android 3.2平板电脑模拟器时,EditText形状几乎不可能看到。它看起来像是在白纸上画白纸。如图所示: 当我在Android 4.0平板电脑模拟器上使用它时,EditText形状看起来很好。您可以看到编辑文本底部的深灰色线条。如果您查看上图,您将几乎看不到与浅灰色背景水印相交的同一位置的白线 以下是布局中的编辑文本: <EditText android:id="@+id

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

当我使用Android 3.2平板电脑模拟器时,EditText形状几乎不可能看到。它看起来像是在白纸上画白纸。如图所示:

当我在Android 4.0平板电脑模拟器上使用它时,EditText形状看起来很好。您可以看到编辑文本底部的深灰色线条。如果您查看上图,您将几乎看不到与浅灰色背景水印相交的同一位置的白线

以下是布局中的编辑文本:

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

0.65
10dp
0dp
填补家长的空缺
10dp

为什么我的编辑文本绘制错误的颜色?我没有覆盖绘图代码或背景绘图

我解决了我的问题。通过在manifest.xml文件的application元素
android:theme=“@android:style/theme”
中设置主题

<application 

android:label="@string/app_name" 

android:icon="@drawable/logo" 

android:vmSafeMode="false" 

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


试试这个。

如果您使用以下主题,您可以拥有一个操作栏,并且仍然可以看到
编辑文本
浅灰色背景水印:

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>

@样式/MyActionBar
@颜色/黑色

这适用于主题“android:theme.Holo.Light”,但不适用于主题“android:theme.Holo”。

其他答案实际上并不是我问题的解决方案,我从未找出问题的真正原因。然而,我就是这样解决的:我的解决办法是从冰淇淋三明治复制.9.pngs和EditText小部件的样式,并硬编码到我的蜂窝和冰淇淋三明治应用程序中

编辑:

我创建了一个名为res/drawable nodpi/edit_text_holo_light.xml的文件,其中包含以下内容:

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

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

<item name="android:background">@drawable/edit_text_holo_light</item>
@可绘制/编辑文字全息灯

然后我从android sdk复制了.9.png文件,并将它们放在res/drawable-*中。文件名列在上面的xml中。

嗨,Kenny Wyland,你解决问题了吗。我也面临着同样的问题。我从未解决过这个问题,但我的解决办法是复制冰淇淋三明治中的.9.png和样式,并将其硬编码到我的蜂窝和冰淇淋三明治应用程序中。请参阅下面的链接,我使用的是标准安卓主题。Holo,但它在3.0之前是不存在的,所以我使用谷歌提供的标准代码在Theme和基于OS版本的Theme.Holo之间切换。问题不是我没有使用主题。。问题在于主题。蜂窝上的全息在所有设备上都不能正常工作。我也有同样的问题。我正在摩托罗拉Xoom平板电脑上测试我的应用程序。我已经设置了Theme.Holo,但没有任何改变(编辑文本仍然融入背景)。可能我还需要做一些硬编码。我遇到了同样的问题,请告诉我有关如何修复此问题的更多详细信息。我进入android sdk文件夹查找用于绘制标准文本字段的.9.png文件。例如,其中一个名为textfield_activated_holo_light.9.png。我将所有这些文件复制到我的res/drawable-v11目录中,这样它们就可以用于v11之后的任何Android版本。然后我添加了一个可绘制的nodpi/edit_text_holo_light.xml,并在其中复制了原始Android样式中的样式。(这里包含的内容太多,我将更新我的答案)