I have a simple layout with edittext.
When I set the background EditTextto color
<EditText
android:id="@+id/et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@android:color/white" />
Then the strange thing happens, when the focus of the edittext focuses, the background color of the layout changes (!).
I need to change the background color dynamically, and after the call, I get the same result:
subject.setBackgroundColor(Color.parseColor(mycolor));
I also tried the following method:
subject.setBackground(new ColorDrawable(Color.parseColor(mycolor)));
The result was the same.
Basically I want to change the background color of the Edittext at runtime.
source
share