0

这个 XML:

<TextView
    android:text="@string/verify_code_upc"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_row="1"
    android:layout_column="0"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="#000080" />

<EditText
    android:id="@+id/editTextUPC"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:background="#ffcb05"
    android:layout_row="1"
    android:layout_column="1"
    android:layout_columnSpan="5" />

...显示了这一点:

在此处输入图像描述

但是添加这个:

android:background="#ffcb05"

...到 EditText 会导致整个 EditText “消失”:

在此处输入图像描述

为什么?

更新

如果我给它一个明确的宽度:

android:width="240dp"

...它确实显示:

在此处输入图像描述

4

2 回答 2

1

因为颜色没有大小。颜色drawables没有特定的大小,所以你必须给它一个。另一种选择是使用可绘制对象而不是颜色。

于 2014-05-19T19:12:53.967 回答
1

将您的 EditText 更改为

<EditText android:id="@+id/editTextUPC" android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="#ffcb05" android:layout_row="1" android:layout_column="1" android:hint="Hint occupying space" android:layout_columnSpan="5" />

或更改

 android:layout_width="match_parent"
于 2014-05-19T19:44:13.090 回答