[Android UI] case 02 Implementation of rounded border and rounded corner background (shape), androidui

Source: Internet
Author: User

[Android UI] case 02 Implementation of rounded border and rounded corner background (shape), androidui

This article describes how to implement the border and background. For more information about how to use shape, see http://blog.csdn.net/mahoking/article/details/23672271. This document provides a detailed introduction.

[For more information, see http://blog.csdn.net/mahoking]
The following is the demo shape_layout.xml template.

<? Xml version = "1.0" encoding = "UTF-8"?> <Shape xmlns: android = "http://schemas.android.com/apk/res/android"> <! -- Fill color --> <solid android: color = "# CCFF99"/> <! -- Rounded corner --> <corners android: radius = "10dp"/> </shape>

In order to see and coordinate the display, multiple shapes _ * are created in this case _*. xml file, each shape _*. the xml file only has different settings for the fill color of solid. You can configure the fill color based on your own design and preferences. At the end of this article, the corresponding Demo will be displayed.

<? Xml version = "1.0" encoding = "UTF-8"?> <Shape xmlns: android = "http://schemas.android.com/apk/res/android"> <! -- Fill color --> <solid android: color = "# FF9999"/> <! -- Rounded corner --> <! -- Android: radius sets the radians of the angle. The greater the value, the greater the angle is. --> <corners android: radius = "10dp"/> </shape>

Create a RoundCornerActivity. The layout file is activity_01_round_corner.xml.
RoundCornerActivity

/*** @ Describe implementation demonstration of the border and background of the rounded corner * @ date 22:35:49 */public class RoundCornerActivity extends Activity {@ Overrideprotected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_01_round_corner );}}

Activity_01_round_corner.xml

<? Xml version = "1.0" encoding = "UTF-8"?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "match_parent" android: layout_height = "match_parent" android: orientation = "vertical"> <TextView android: layout_width = "match_parent" android: layout_height = "20dp" android: layout_marginLeft = "15dp" android: layout_marginRight = "15dp" android: layout_marginTop = "5dp" android: background = "@ drawable/shape_01_round_corner_textview" android: gravity = "center" android: text = ""/> <LinearLayout android: layout_width = "match_parent" android: layout_height = "60dp" android: layout_marginLeft = "15dp" android: layout_marginRight = "15dp" android: layout_marginTop = "10dp" android: background = "@ drawable/layout"> </LinearLayout> <TextView android: layout_width = "match_parent" android: layout_height = "20dp" android: layout_marginLeft = "15dp" android: layout_marginRight = "15dp" android: layout_marginTop = "5dp" android: background = "@ drawable/shape_01_round_corner_textview" android: gravity = "center" android: text = "special effect demonstration"/> <LinearLayout android: layout_width = "match_parent" android: layout_height = "wrap_content" android: layout_marginTop = "10dp" android: orientation = "horizontal"> <LinearLayout android: layout_width = "match_parent" android: layout_height = "wrap_content" android: Layout = "5dp" android: layout_marginRight = "5dp" android: layout_weight = "1" android: orientation = "vertical"> <TextView android: layout_width = "match_parent" android: layout_height = "120dp" android: background = "@ drawable/shape_01_round_corner_textview_ma" android: gravity = "center" android: text = "Ma" android: textSize = "60dp"/> </LinearLayout> <LinearLayout android: layout_width = "match_parent" android: layout_height = "wrap_content" android: layout_marginLeft = "5dp" android: layout_marginRight = "5dp" android: layout_weight = "1" android: orientation = "vertical"> <TextView android: layout_width = "match_parent" android: layout_height = "55dp" android: background = "@ drawable/shape_01_round_corner_textview_yi" android: gravity = "center" android: text = "Italian" android: textSize = "30dp"/> <TextView android: layout_width = "match_parent" android: layout_height = "55dp" android: layout_marginTop = "10dp" android: background = "@ drawable/shape_01_round_corner_textview_ran" android: gravity = "center" android: text = "ran" android: textSize = "30dp"/> </LinearLayout>

Do not forget to register the Activity in AndroidManifest. xml.

<application        android:allowBackup="true"        android:icon="@drawable/uisharing_ico"        android:label="@string/app_name"        android:theme="@style/AppTheme" >        <activity            android:name="com.mahaochen.app.uisharing.example01.RoundCornerActivity"            android:screenOrientation="portrait"             android:label="@string/app_name">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application>


Run the project as follows:

 




Rounded border in the webpage

Believe me, the background image is your best choice.
Three years of webpage designers ~

CSS rounded Border Code

Generally, it is best to use a background image in a rounded corner frame, so that the compatibility is good and css can also be implemented, but there are some restrictions, because the standards supported by different browsers are different.
I recommend you read an article
Hi.baidu.com/...1.html

In addition, the ajax control of asp.net also has a rounded corner box RoundedCorners
Demo address
Www.asp.net/..s.aspx

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.