In the Android development process, often need to change the default style of the control, then often use a number of pictures to solve. However, this approach may require multiple images, such as a button, a model image to be clicked, and a default style image. This makes it easy to make the apk bigger. Another way is to use a custom graphic to change the style of the control.
The custom shape shape has the following properties
1.solid: Fill
2.gradient: Corresponds to a color gradient. StartColor, EndColor will not say much. Android:angle refers to the angle from which the change begins.
3.stroke: Stroke
4.corners: Rounded Corners
5.padding: Spacing defines how far the content is from the boundary
Implementation steps:
1. Create a My_shape.xml file under the drawable file.
2. Writing style code in the My_shape.xml file
<shape xmlns:android= "Http://schemas.android.com/apk/res/android" >
<solid android:color= "#ffffffff"/>
<corners Android:radius = "10DP"/>
<padding android:bottom= "5DP" android:top= "5DP" android:left= "5DP" android:right= "5DP"/>
<stroke android:width= "1DP" android:color= "#ff00bbe8"/>
</shape>
3. Set Android:[email Protected]/my_shape in the control you are using, or you can set it in the style style file.
As follows:
Android Custom Graphics shape