Android:EditText以黑色背景显示
我有一行有两个编辑文本和两个图像按钮。在android studio的预览中,一切看起来都很好,EditText具有默认样式。但如果我在平板电脑上显示,背景是黑色的 它应该是什么样子:Android:EditText以黑色背景显示,android,android-layout,android-edittext,background-color,android-styles,Android,Android Layout,Android Edittext,Background Color,Android Styles,我有一行有两个编辑文本和两个图像按钮。在android studio的预览中,一切看起来都很好,EditText具有默认样式。但如果我在平板电脑上显示,背景是黑色的 它应该是什么样子: 它在平板电脑上的外观: 其他编辑文本框显示正确。 有人知道为什么这些看起来不一样,我怎么能修复它吗 这一行的XML布局如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.
它在平板电脑上的外观:
其他编辑文本框显示正确。 有人知道为什么这些看起来不一样,我怎么能修复它吗 这一行的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>
编辑:
我尝试将背景颜色更改为白色,但edittext会失去其整体风格,因此下划线也将不再显示。这是因为基于设备主题的edittext默认背景更改适用于具有自定义背景的edittext,并以一种简单的方式包括
android:background=“#ffffff”
对于您的edittext这是因为基于设备主题的edittext默认背景更改适用于具有自定义背景的edittext,并且以简单的方式包括android:background=“#ffffffff”
对于您的编辑文本问题可能是由imageButtons引起的,但您可以如下更改编辑文本的背景色:
android:background="#FFFFFF"
youeEditText.setBackgroundColor(Color.parseColor("#ffffff"));
问题可能是由于imageButtons引起的,但您可以如下更改edittext的背景色:
android:background="#FFFFFF"
youeEditText.setBackgroundColor(Color.parseColor("#ffffff"));
可能您的选项卡不支持所选主题,请尝试使用以下方法更改edittext的背景色:
android:background="#FFFFFF"
若问题并没有解决,那个么您可以通过编程方式更改edittext的背景,如下所示:
android:background="#FFFFFF"
youeEditText.setBackgroundColor(Color.parseColor("#ffffff"));
可能您的选项卡不支持所选主题,请尝试使用以下方法更改edittext的背景色:
android:background="#FFFFFF"
若问题并没有解决,那个么您可以通过编程方式更改edittext的背景,如下所示:
android:background="#FFFFFF"
youeEditText.setBackgroundColor(Color.parseColor("#ffffff"));
谢谢你的回答。但当我将背景颜色更改为白色时,EditText的整个样式也会更改。下划线也消失了。@e_卡您是否尝试过更改imageButton图像的颜色?尝试一下,如果它有任何影响,那么它们就是问题的原因。我将图像的颜色更改为白色,但编辑文本没有任何改变。我也完全删除了它们,但它们仍然是黑色的。@e_card我刚刚在我的模拟器中试用了你的代码,它在这里工作得很好。可能是因为背景主题吧?我不这么认为。因为同一片段上的其他编辑文本显示为白色背景,供您回答。但当我将背景颜色更改为白色时,EditText的整个样式也会更改。下划线也消失了。@e_卡您是否尝试过更改imageButton图像的颜色?尝试一下,如果它有任何影响,那么它们就是问题的原因。我将图像的颜色更改为白色,但编辑文本没有任何改变。我也完全删除了它们,但它们仍然是黑色的。@e_card我刚刚在我的模拟器中试用了你的代码,它在这里工作得很好。可能是因为背景主题吧?我不这么认为。由于同一片段上的其他EDITTEXT显示为白色背景,我考虑使用自定义主题,但我认为必须有可能使用默认样式显示它们,因为其他EDITTEXT显示正确。我认为自定义背景很好,这使EDITTEXT在所有设备中看起来都很相似:)I考虑过使用自定义主题,但我认为必须有可能使用默认样式显示它们,因为其他EDITTEXT显示正确。我认为自定义背景很好,这使EDITTEXT在所有设备中看起来都很相似:)