我有一个简单的布局,其中包含一个编辑框。
当我将EditText
的背景设置为一种颜色时
<EditText
android:id="@+id/et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@android:color/white" />
当EditText获得焦点时,布局的背景颜色会发生奇怪的变化!
我需要动态更改背景颜色,但是调用以下方法后仍然出现相同结果:
subject.setBackgroundColor(Color.parseColor(mycolor));
我也尝试了以下方法:
subject.setBackground(new ColorDrawable(Color.parseColor(mycolor)));
结果是相同的。
基本上,我想在运行时更改EditText的背景颜色。