Android:EditText显示黑色背景
我有一行有两个EditText和两个ImageButton。在android studio的预览中,一切都很好,EditTexts有默认的样式。但是如果我在平板电脑上显示它的背景是黑色的。Android:EditText显示黑色背景
究竟应该如何样子:
它是如何看起来像在平板电脑上:
其他的EditText盒正确显示。 有谁知道为什么这些看起来不同,我该如何解决它?
下面这一行的XML-布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerHorizontal="true"
>
<EditText
android:id="@+id/first_input"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<EditText
android:id="@+id/second_input"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2.4"
/>
<ImageButton
android:id="@+id/first_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:src="@drawable/move"
android:background="@drawable/first_button_background"
android:onClick="onFirstButtonClicked"
/>
<ImageButton
android:id="@+id/second_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:src="@drawable/trash"
android:background="@drawable/second_button_background"
android:onClick="onSecondButtonClicked"
/>
</LinearLayout>
编辑: 我试图改变背景颜色为白色,但随后EditTexts失去他们的整体风格也是如此下划线将不再显示。
这是因为基于设备主题editext默认背景变化去自定义背景一个EditText和以简单的方式包括:android:background="#ffffff"
您editexts
问题可能是由于imageButtons正在发生,但你可以改变在EditText上的背景色是这样的:
android:background="#FFFFFF"
thx为您的答案。但是当我将背景颜色更改为白色时,EditText的整个样式也会发生变化。所以下划线也消失了。 – 2015-04-02 12:43:33
@e_card您是否尝试更改imageButton图像的颜色? 尝试,如果它有任何影响,那么他们是问题的原因 – Umair 2015-04-02 12:46:06
我改变了图像的颜色为白色,但它没有改变任何与EditTexts。我也完全删除它们,它们仍然保持黑色。 – 2015-04-02 12:54:04
可能是你的标签不支持选定的主题,请尝试使用改变你的EditText的背景色:
android:background="#FFFFFF"
如果问题不解决,那么你可以以编程方式更改的EditText的背景是这样的:
youeEditText.setBackgroundColor(Color.parseColor("#ffffff"));
我想到了使用自定义主题,但我认为都必须有默认的样式,以显示他们的可能性因为其他EditTexts正确显示 – 2015-04-02 12:45:33
已尝试android:background =“#ffffff”?? – 2015-04-02 12:46:58
是的,我做到了。但然后EditTexts失去了他们的风格,像下划线.. – 2015-04-02 12:49:48