Use of Android shape
The button inside the layout file is then set as follows:
[Java]View PlainCopy
- <button
- android:id="@+id/button1"
- Android:layout_width="Wrap_content"
- android:layout_height="Wrap_content"
- android:text="Button1"
- android:background="@drawable/buttonstyle"/>
Shape is used for setting shapes, can be used in selector,layout and so on, there are 6 sub-tags, the properties are as follows:
[Java]View PlainCopy
- <?xml version="1.0" encoding="Utf-8"?>
- <shape xmlns:android="http://schemas.android.com/apk/res/android" >
- <!--rounded corners--
- <corners
- android:radius="9DP"
- android:topleftradius="2DP"
- android:toprightradius="2DP"
- android:bottomleftradius="2DP"
- android:bottomrightradius="2DP"/><!--set the fillet radius --
- <!--gradients--
- <gradient
- Android:startcolor="@android: Color/white"
- Android:centercolor="@android: Color/black"
- Android:endcolor="@android: Color/black"
- Android:uselevel="true"
- " android:angle="
- android:type="Radial"
- android:centerx="0"
- android:centery="0"
- android:gradientradius="/> "
- <!--Interval--
- <padding
- android:left="2DP"
- android:top="2DP"
- android:right="2DP"
- android:bottom="2DP"/><!--every direction--
- <!--size-
- <size
- Android:width="50DP"
- android:height="50DP"/><!--width and height --
- <!---filled
- <solid
- Android:color="@android: Color/white"/><!--Fill Color--
- <!--strokes--
- <stroke
- Android:width="2DP"
- Android:color="@android: Color/black"
- Android:dashwidth="1DP"
- android:dashgap="2DP"/>
- </shape>
Use of Android shape