Reputation:
I want to change all EditText UI In android. For example I want to change On Focus, On Blur and ... style. How can I do it? Actually I read some snippet, but I don't understand what they do!
Upvotes: 0
Views: 2309
Reputation: 33534
If you want to change the looks of EditText when certain events like onFocus, onPressed too place, then you will need Selector.
Selector is a drawable and is implemented as xml file, the elements in selector files will refer to specific state. Each Element maps to a specific state.
To change the look and feel of UI components, you can use background, src attributes,etc.
and this link is just the one thats needed.
http://developer.android.com/guide/topics/ui/themes.html
Upvotes: 0
Reputation: 15701
1- create selector for different state
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/textfield_default" />
<item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_disabled" />
<item android:state_pressed="true" android:drawable="@drawable/textfield_pressed" />
<item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_selected" />
<item android:state_enabled="true" android:drawable="@drawable/textfield_default" />
<item android:state_focused="true" android:drawable="@drawable/textfield_disabled_selected" />
<item android:drawable="@drawable/textfield_disabled" />
</selector>
2- To apply the customize drawable xml use the android:backgroung attibute of the EditText
android:background="@drawable/yourXml"
http://www.androidworks.com/changing-the-android-edittext-ui-widget
Upvotes: 3