Android Development Tips Four--rounded controls to make it look more beautiful

Source: Internet
Author: User

When you need to select a background for the application UI control, the developer adds custom colors and shapes to replace the system's default style.

Rounded borders look like a good effect, and developers just need to add a few lines of code to use this effect in your application.

Let's take a look at the following example and create a new Main.xml code:

<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android"    xmlns:tools= "http// Schemas.android.com/tools "    android:id=" @+id/container "    android:layout_width=" Match_parent "    Android : layout_height= "match_parent"    android:orientation= "vertical" >    <button        android:layout_width= " Wrap_content "        android:layout_height=" wrap_content "        android:layout_gravity=" center "        Android:layout_ margintop= "50DP"        android:background= "@drawable/button_rounded_background"        android:gravity= "Center_ Vertical "        android:padding=" 10DP "        android:text=" Hello,roundcornerdemo "        android:textcolor=" # FFFFFF "/></linearlayout>

Where we specify the drawable value for the Background property, but this value is not a picture, but an XML file. The file code is as follows:

<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android" >    <solid android:color= "#02A712"/>    <corners android:radius= "15DP"/></shape>

Just two lines of code. Let's take a look at the effect:


is not more gentle and feminine than the default style of square!

Like a friend can pay attention to me! Thanks for your support!

Android Development Tips Four--rounded controls to make it look more beautiful

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.