我有两行EditTexts和两个ImageButtons。在android studio的预览中,一切看起来都很好,EditTexts也有默认样式。但如果我在平板电脑上显示背景是黑色的。
它应该如何:
平板电脑的样子:
正确显示其他EditText-Box。 有谁知道为什么这些看起来不同以及我如何解决它?
这一行的XML-Layout:
<?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失去了整个样式,因此下划线将不再显示。
答案 0 :(得分:3)
这是因为基于设备主题的editext默认背景更改用于具有自定义背景的编辑文本,并且以简单的方式包含android:background="#ffffff"
用于您的editexts
答案 1 :(得分:1)
由于imageButtons可能会出现问题,但您可以像这样更改编辑文本的背景颜色:
android:background="#FFFFFF"
答案 2 :(得分:0)
可能是您的标签不支持所选主题,请尝试使用以下方法更改编辑文字的背景颜色:
android:background="#FFFFFF"
如果问题无法解决,那么您可以通过编程方式更改edittext的背景:
youeEditText.setBackgroundColor(Color.parseColor("#ffffff"));