Implementation of text box for creating rounded corners in android

Source: Internet
Author: User

In many android applications, we often see the text editing box with rounded corners. How is that implemented?


Two shape drawing files are required.

For the top EditText, call this, top_edittext_bg:

[Javascript]
01. <? Xml version = "1.0" encoding = "UTF-8"?>
02. <shape xmlns: android = "http://schemas.android.com/apk/res/android"
03. android: shape = "rectangle">
04.
05. <solid
06. android: color = "# e2e2e2">
07. </solid>
08.
09. <corners
10. android: radius = "1dp"
11. android: bottomLeftRadius = "0.1dp"
12. android: bottomRightRadius = "0.1dp"
13. android: topLeftRadius = "5dp"
14. android: topRightRadius = "5dp">
15. </corners>
16.
17. </shape>
<? Xml version = "1.0" encoding = "UTF-8"?>
<Shape xmlns: android = "http://schemas.android.com/apk/res/android"
Android: shape = "rectangle">

<Solid
Android: color = "# e2e2e2">
</Solid>

<Corners
Android: radius = "1dp"
Android: bottomLeftRadius = "0.1dp"
Android: bottomRightRadius = "0.1dp"
Android: topLeftRadius = "5dp"
Android: topRightRadius = "5dp">
</Corners>

</Shape>
For the EditText in the middle, call this, bottom_edittext_bg:


[Javascript]
01. <? Xml version = "1.0" encoding = "UTF-8"?>
02. <shape xmlns: android = "http://schemas.android.com/apk/res/android"
03. android: shape = "rectangle">
04.
05. <solid
06. android: color = "# e2e2e2">
07. </solid>
08.
09. <corners
10. android: radius = "1dp"
11. android: bottomLeftRadius = "5dp"
12. android: bottomRightRadius = "5dp"
13. android: topLeftRadius = "0.1dp"
14. android: topRightRadius = "0.1dp">
15. </corners>
16.
17. </shape>
<? Xml version = "1.0" encoding = "UTF-8"?>
<Shape xmlns: android = "http://schemas.android.com/apk/res/android"
Android: shape = "rectangle">

<Solid
Android: color = "# e2e2e2">
</Solid>

<Corners
Android: radius = "1dp"
Android: bottomLeftRadius = "5dp"
Android: bottomRightRadius = "5dp"
Android: topLeftRadius = "0.1dp"
Android: topRightRadius = "0.1dp">
</Corners>

</Shape> then set this attribute in android: background = "@ drawable/RESPECTIVE_XMLS" to the associated EditText's


 

Related Article

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.