<span id="Label3"></p><p><p>1. Remove the Border</p></p><p><p></p></p><p><p></p></p><p>Edittext's Background property is set to @null: android:background= "@null"<br>The style property can be added without adding<br><br>Attached Original:<br>@SlumberMachine, that ' s a great observation! but, It seems that there was more to making a TextView editable than just setting android:editable= "true". It has to does with the ' input method '-what ever this is-and that's where the real difference between TextView and Edit Text Lies. TextView is designed with a EditText in mind, That's for Sure. One would has a to look at the EditText source code and probably EditText style to see what's really going on there. Documentation is simply not enough.<br><br>I have asked the same question back at Android-developers group, and got a satisfactory answer. This is the what are you having to do:<br><br>Xml:<br><edittext android:id= "@+id/title" android:layout_width= "fill_parent"<br>style= "? android:attr/textviewstyle"<br>android:background= "@null" android:textcolor= "@null"/><br><br><br>Instead of style= "? android:attr/textviewstyle" You can also write style= "@android: style/widget.textview", don ' t ask me wh Y and what it means.</p><p><p>2.Android EditText Change Border color</p></p><p><p></p></p><p><p>The first step: for a better comparison, prepare two identical edittext (when the activity starts, the focus will be on the first edittext, if you do not want this only need to write a height and broadband of the edittext can be avoided, this does not do so), the code is as Follows:</p></p><p><p></p></p><strong><strong>[html]</strong></strong>View Plaincopy <ol class="dp-xml" start="1"> <li class="alt"><li class="alt"><span class="tag"><<span class="tag-name">EditText</span></span></li></li> <li><li><span class="attribute">android:layout_width=<span class="attribute-value">"fill_parent"</span> </span></li></li> <li class="alt"><li class="alt"><span class="attribute">android:layout_height=<span class="attribute-value">"36dip"</span> </span></li></li> <li><li><span class="attribute">android:background=<span class="attribute-value">"@drawable/bg_edittext"</span> </span></li></li> <li class="alt"><li class="alt"><span class="attribute">android:padding=<span class="attribute-value">"5dip"</span> </span></li></li> <li><li><span class="attribute">android:layout_margin=<span class="attribute-value">"36dip"</span> </span></li></li> <li class="alt"><li class="alt"><span class="attribute">android:textcolorhint=<span class="attribute-value">"#AAAAAA"</span> </span></li></li> <li><li><span class="attribute">android:textsize=<span class="attribute-value">"15dip"</span> </span></li></li> <li class="alt"><li class="alt"><span class="attribute">android:singleline=<span class="attribute-value">"true"</span> </span></li></li> <li><li><span class="attribute">android:hint=<span class="attribute-value">"please enter ..."</span> </span></li></li> <li class="alt"><li class="alt"><span class="tag">/></span></li></li> </ol><p><p><br>next, create three XML files, respectively, when the input box does not have the focus of the background, the input box when the focus of the background, selector background selector (here to get the input box when to get and lose focus), the code is as Follows:</p></p><p><p>Bg_edittext_normal.xml (when no focus is received)</p></p><strong><strong>[html]</strong></strong>View Plaincopy <ol class="dp-xml" start="1"> <li class="alt"><li class="alt"><span class="tag"><? <span class="tag-name">XML <span class="attribute">version= "<span class="attribute-value">1.0" <span class="attribute">encoding=<span class="attribute-value">"UTF-8"<span class="tag">?></span> </span> </span> </span> </span> </span></span></li></li> <li><li><span class="tag"><<span class="tag-name">shape <span class="attribute">xmlns:android=<span class="attribute-value">"http://schemas.android.com/apk/res/android"<span class="tag">></span> </span> </span> </span></span></li></li> <li class="alt"><li class="alt"><span class="tag"><<span class="tag-name">solid <span class="attribute">android:color=<span class="attribute-value">"#FFFFFF" <span class="tag">/></span> </span> </span> </span> </span></li></li> <li><li><span class="tag"><<span class="tag-name">corners <span class="attribute">android:radius=<span class="attribute-value">"3dip"<span class="tag">/></span> </span> </span> </span> </span></li></li> <li class="alt"><li class="alt"><span class="tag"><<span class="tag-name">stroke</span> </span></li></li> <li><li><span class="attribute">android:width=<span class="attribute-value">"1dip"</span> </span></li></li> <li class="alt"><li class="alt"><span class="attribute">android:color=<span class="attribute-value">"#BDC7D8" <span class="tag">/></span> </span> </span></li></li> <li><li><span class="tag"></<span class="tag-name">shape<span class="tag">></span> </span></span></li></li> </ol><p><p>Bg_edittext_focused.xml (when gaining Focus)</p></p><strong><strong>[html]</strong></strong>View Plaincopy <ol class="dp-xml" start="1"> <li class="alt"><li class="alt"><span class="tag"><? <span class="tag-name">XML <span class="attribute">version= "<span class="attribute-value">1.0" <span class="attribute">encoding=<span class="attribute-value">"UTF-8"<span class="tag">?></span> </span> </span> </span> </span> </span></span></li></li> <li><li><span class="tag"><<span class="tag-name">shape <span class="attribute">xmlns:android=<span class="attribute-value">"http://schemas.android.com/apk/res/android"<span class="tag">></span> </span> </span> </span></span></li></li> <li class="alt"><li class="alt"><span class="tag"><<span class="tag-name">solid <span class="attribute">android:color=<span class="attribute-value">"#FFFFFF" <span class="tag">/></span> </span> </span> </span> </span></li></li> <li><li><span class="tag"><<span class="tag-name">corners <span class="attribute">android:radius=<span class="attribute-value">"3dip"<span class="tag">/></span> </span> </span> </span> </span></li></li> <li class="alt"><li class="alt"><span class="tag"><<span class="tag-name">stroke</span> </span></li></li> <li><li><span class="attribute">android:width=<span class="attribute-value">"1dip"</span> </span></li></li> <li class="alt"><li class="alt"><span class="attribute">android:color=<span class="attribute-value">"#728ea3" <span class="tag">/></span> </span> </span></li></li> <li><li><span class="tag"></<span class="tag-name">shape<span class="tag">></span> </span></span></li></li> </ol><p><p>Bg_edittext.xml (selector selector, This information online a lot)</p></p><strong><strong>[html]</strong></strong>View Plaincopy <ol class="dp-xml" start="1"> <li class="alt"><li class="alt"><span class="tag"><? <span class="tag-name">XML <span class="attribute">version= "<span class="attribute-value">1.0" <span class="attribute">encoding=<span class="attribute-value">"UTF-8"<span class="tag">?></span> </span> </span> </span> </span> </span></span></li></li> <li><li><span class="tag"><<span class="tag-name">selector <span class="attribute">xmlns:android=<span class="attribute-value">"http://schemas.android.com/apk/res/android"<span class="tag">></span> </span> </span></span></span></li></li> <li class="alt"><li class="alt"><span class="tag"><<span class="tag-name">item <span class="attribute">android:state_window_focused=<span class="attribute-value">"false" <span class="attribute">android:drawable=<span class="attribute-value">"@drawable/contact_edit_ Edittext_normal " <span class="tag">/></span> </span> </span> </span> </span> </span> </span></li></li> <li><li><span class="tag"><<span class="tag-name">item <span class="attribute">android:state_focused=<span class="attribute-value">"true" <span class="attribute">android:drawable=<span class="attribute-value">"@drawable/contact_edit_ edittext_focused " <span class="tag">/></span> </span> </span> </span> </span> </span> </span></li></li> <li class="alt"><li class="alt"><span class="tag"></<span class="tag-name">selector<span class="tag">></span> </span></span></li></li> </ol><p><p><br>This will be ok, as Follows:</p></p><p><p></p></p><p><p>The second input box border becomes dark, and is not so friendlier.</p></p><p><p>Android EditText Custom Styles</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service