Android Set Rounded Rectangle

Source: Internet
Author: User

1. Add a resource file

// res/drawable/bg_btn_round_corner.xml<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android"    android:shape= "Rectangle" >    <corners Android : radius= "16DP"/>    <solid android:color= "#ff7777"/>    <stroke        android:width= "2DP"         Android:color= "#0000ff"/>    <gradient        android:endcolor= "#ff7777"         Android:startcolor= "#ff0000"/></shape>

The resulting preview is shown below:

Because the gradient property is also used above, the solid property does not work. If the interior is solid color, you can configure only the solid property. Gradient represents the gradient effect.

2. Use this resource in the layout file, and use the same method as the picture resource.

<button        android:layout_width= "        android:layout_height" = "60DP"        android: Background= "@drawable/bg_btn_round_corner"        android:text= "Hello"        android:textsize= "18sp"/>

The result is this.

Android Set Rounded Rectangle

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.