The example in this article describes the Android EditText custom style approach. Share to everyone for your reference, specific as follows:
1. Remove the border
EditText's Background property is set to @null: android:background= "@null"
The style attribute can be added without
Attached Original:
@SlumberMachine, that ' s a great observation! But, it seems that there was more to making a TextView editable than "true". It has to does with the ' input method '-what ever that Is-and, where the real difference between and Edit Text lies. TextView is designed with a edittext in mind, which is for sure. One would have to look in the EditText source code and probably edittext style to the what really ' s going on there. Documentation is simply not enough.
I have asked the same question back at Android-developers Group, and got a satisfactory answer. This is what you have TODO:
Xml:
<edittext android:id= "@+id/title" android:layout_width= "fill_parent" style= "Android:attr/textviewstyle"
android:background= "@null" android:textcolor= "@null"/>
Instead of style= "? Android:attr/textviewstyle" can also write style= "@android: Style/widget.textview", Don t ask me wh Y and what it means.
2.Android edittext Change Border color
First step: For better comparison, prepare two identical edittext (when the activity starts, the focus will be on the first edittext, if you do not want to write a height and broadband for 0 EditText can be avoided, this is not done here), the code is as follows:
<edittext
android:layout_width= "fill_parent"
android:layout_height= "36dip"
android:background= " @drawable/bg_edittext "
android:padding=" 5dip "
android:layout_margin=" 36dip "
android:textcolorhint = "#AAAAAA"
android:textsize= "15dip"
android:singleline= "true"
android:hint= "Please enter ..."
/>
Next, create three XML files, which are the background when the input box does not have the focus, the background when the input box is focused, the selector background selector (where you can get the input box to get and lose focus), the code is as follows:
Bg_edittext_normal.xml (when focus is not available)
<?xml version= "1.0" encoding= "UTF-8"?> <shape xmlns:android=
"http://schemas.android.com/apk/res/" Android ">
<solid android:color=" #FFFFFF "/>
<corners android:radius=" 3dip "/>
< Stroke
android:width= "1dip"
android:color= "#BDC7D8"/>
</shape>
Bg_edittext_focused.xml (when getting focus)
<?xml version= "1.0" encoding= "UTF-8"?> <shape xmlns:android=
"http://schemas.android.com/apk/res/" Android ">
<solid android:color=" #FFFFFF "/>
<corners android:radius=" 3dip "/>
< Stroke
android:width= "1dip"
android:color= "#728ea3"/>
</shape>
Bg_edittext.xml (selector selector, a lot of this information online)
<?xml version= "1.0" encoding= "UTF-8"?> <selector xmlns:android=
"http://schemas.android.com/apk/res/" Android ">
<item android:state_window_focused=" false "android:drawable=" @drawable/contact_edit_edittext _normal "/>
<item android:state_focused=" true "android:drawable=" @drawable/contact_edit_edittext_ Focused "/>
</selector>
This is OK, the effect chart is as follows:
The second input box border changes to a darker color, so it's a bit more friendly.
More interested readers of Android-related content can view this site: "Introduction to Android Development and advanced Course", "Android Communication Summary", "Android Basic Components Usage Summary", "Android View Summary", " Android Layout layout Tips and a summary of the use of Android controls
I hope this article will help you with the Android program.