Android develops a method to realize rounded rectangle based on drawable
This paper describes the method of developing rounded rectangle based on drawable for Android. Share with you for your reference, as follows:
Step 1: write a class to inherit drawable, rewrite the methods inside, and the core code of the implementation is in draw
Key technology: bitmapshader
public BitmapShader(Bitmap bitmap,Shader.TileMode tileX,Shader.TileMode tileY)
Call this method to generate a shader with a bitmap drawn.
Bitmap tile the tiling mode for X to draw the bitmap in. Tile the tiling mode for y to draw the bitmap in. Tile the tiling mode for y to draw the bitmap in
Tilemode: clamp: if the renderer is outside the original boundary, the edge coloring in the range is copied. Repeat: repeat renderer images horizontally and vertically, tiled. Mirror: horizontal and vertical repeat renderer images. This is different from repeat repeat. It is tiled in a mirror way.
Step 2: implementation class
activity_ round_ drawable.xml
Draw a circular picture
Core code:
More readers interested in Android related content can view the special topics of this site: summary of Android graphics and image processing skills, introduction and advanced tutorial of Android development, summary of Android debugging skills and common problem solving methods, summary of Android basic component usage, summary of Android view skills, summary of Android layout skills, and Android control usage summary
I hope this article will help you in Android programming.