Android---edittext yellow border

Source: Internet
Author: User

Http://liuzhichao.com/p/612.html

Customizing the Android control EditText border background

Liu Zhishu blog ?  program? andriod ? Customizing the Android control edittext border background

Posted in andriodOn 2011/06/02by Liuzc

In our Android application interface design and, for the sake of the unity of the interface style, we need to customize some of the controls. For example, our app uses the blue style, but Android's EditText control gets the focus and the yellow border background is displayed. So how do you get EditText to show our custom blue background when we get the focus?

The

first prepares two pictures, one for the background of the edittext after the focus, one for the background without the focus, attention to the 9.png style of the picture, and then a selector_edittext_ in the drawable. Bg.xml file with the following contents:

<?  xml version  =   "1.0"   encoding  =   "Utf-8"  ?>  <selector  xmlns:android  =   "http://schemas.android.com/apk/res/android"  >  <item  android:drawable  =   "@drawable/edit_pressed"  android:state_focused  =   "true"  />  <item  android:drawable  =   "@drawable/edit_normal"  />  </SELECTOR>  

then create a new Style.xml file under the Values folder with the following contents:

<? XML version = "1.0" encoding = "Utf-8" ?> <resources> <style name = "My_edittext_style" Parent = "@android: Style/widget.edittext" > <item name = "Android:background" > @drawable/SELECTOR_EDITTEXT_BG </item> </style> </resources>

Finally, we can use our new style on the Edittex:

<edittextAndroid:id="@+id/v_value"style="@style/My_edittext_style"Android:layout_width="0.0dip"Android:layout_height="Wrap_content"Android:layout_weight="1"Android:hint="@string/edit_key"android:imeoptions="Actiondone"Android:inputtype=""/>

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.