Android Development Note ___shape

Source: Internet
Author: User

Shape_oval

1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Shapexmlns:android= "Http://schemas.android.com/apk/res/android"3 Android:shape= "Oval" >4 5     <SolidAndroid:color= "#ff66aa" />6 7     <Stroke8         Android:width= "1DP"9 Android:color= "#ffaaaaaa" />Ten  One </Shape>

Default Rectangle

1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Shapexmlns:android= "Http://schemas.android.com/apk/res/android" >3 4     <SolidAndroid:color= "#ffdd66" />5 6     <Stroke7         Android:width= "1DP"8 Android:color= "#ffaaaaaa" />9 Ten     <Corners One         Android:bottomleftradius= "10DP" A Android:bottomrightradius= "10DP" - Android:topleftradius= "10DP" - Android:toprightradius= "10DP" /> the  - </Shape>

Xml

1 <?XML version= "1.0" encoding= "Utf-8"?>2 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"3 Android:layout_width= "Match_parent"4 Android:layout_height= "Match_parent"5 android:orientation= "vertical">6 7     <View8         Android:id= "@+id/v_content"9 Android:layout_width= "Match_parent"Ten Android:layout_height= "200DP" One Android:layout_margin= "20DP" /> A  -     <LinearLayout -         Android:layout_width= "Match_parent" the Android:layout_height= "Wrap_content" - android:orientation= "Horizontal"> -  -         <Button +             Android:id= "@+id/btn_rect" - Android:layout_width= "0DP" + Android:layout_height= "Wrap_content" A Android:layout_weight= "1" at Android:text= "Rounded Rectangle background" - Android:textcolor= "#000000" - android:textsize= "17SP" /> -  -         <Button -             Android:id= "@+id/btn_oval" in Android:layout_width= "0DP" - Android:layout_height= "Wrap_content" to Android:layout_weight= "1" + Android:text= "Oval Background" - Android:textcolor= "#000000" the android:textsize= "17SP" /> *  $     </LinearLayout>Panax Notoginseng  - </LinearLayout>

Java

1  PackageCom.example.alimjan.hello_world;2 3 ImportAndroid.content.Context;4 Importandroid.content.Intent;5 ImportAndroid.os.Bundle;6 Importandroid.support.v7.app.AppCompatActivity;7 ImportAndroid.view.View;8 ImportAndroid.widget.Button;9 Ten /** One * Created by Alimjan on 7/1/2017. A  */ -  -  Public classClass__2_4_3extendsAppcompatactivityImplementsView.onclicklistener { the  -     PrivateView v_content; -  - @Override +     protected voidonCreate (Bundle savedinstancestate) { -         Super. OnCreate (savedinstancestate); + Setcontentview (r.layout.code_2_4_3); AV_content =(View) Findviewbyid (r.id.v_content); at  -Button Btn_rect =(Button) Findviewbyid (r.id.btn_rect); -Button Btn_oval =(Button) Findviewbyid (r.id.btn_oval); -Btn_rect.setonclicklistener ( This); -Btn_oval.setonclicklistener ( This); -     } in  - @Override to      Public voidOnClick (View v) { +         if(V.getid () = =r.id.btn_rect) { - V_content.setbackgroundresource (r.drawable.shape_rect_gold); the}Else if(V.getid () = =r.id.btn_oval) { * V_content.setbackgroundresource (r.drawable.shape_oval_rose); $         }Panax Notoginseng     } -  the      Public Static voidstarthome (Context mcontext) { +Intent Intent =NewIntent (Mcontext, Class__2_4_3.class); A mcontext.startactivity (intent); the     } +  -}

1. There are four types of shape

Rectangle Rectangle

Oval ellipse (Corners attribute Invalid)

Line lines (The Stroke property must be set)

Ring Ring

2, Corners

Bottomleftradius: Lower left corner

Bottomrightradius: Lower right corner

Topleftradius: Upper left corner

Toprightradius: Upper right corner

3, Gradien (color gradient)

Linear: Linear gradient

Radial: Radiation gradients

Sweep: Scrolling Gradient

4, padding interval size

5 Size of size graphic

6. Solid Interior Fill Color

7, the stroke around the transition

Color

Dashgap: Interval between dashes of each segment

Dashwidth: Dashed width per segment

Width: Thickness of stroke

Android Development Note ___shape

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.