My EditText
has some color, but when I enter some text it should change. Say it's grey, I started to enter and it's yellow. This EditText
is also focused, so when this activity starts -- I already can enter the text. How I tried:
<style name="LoginEnterField">
<item name="android:textColorHint">@color/black</item>
<item name="android:textColor">@color/black</item>
<item name="android:background">@drawable/selector_edittext</item>
<item name="android:textSize">@dimen/general_text_size</item>
<item name="android:paddingLeft">@dimen/activity_inner_horizontal_margin</item>
<item name="android:paddingRight">@dimen/activity_inner_horizontal_margin</item>
</style>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/grey"/>
<corners android:radius="5dp" />
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/yellow"/>
<corners android:radius="5dp" />
</shape>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@drawable/roundbox_active_style"/>
<item android:drawable="@drawable/roundbox_inactive_style" />
</selector>
I think the point is in this selector. My EditText changes color, but it always yellow. How to make it became yellow only if I enter some text? I can't make any code changes! It's very important. I can't add or change only xml files.
EDIT: It's impossible to do from xml only, so make code changes.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…