Android custom drawable to achieve fillet effect

Drawable is a carrier that can draw resources, such as graphics, images and so on. It can be used as the background of view in actual development. There are two main methods: static and dynamic. Static is used through XML description, and dynamic is user-defined drawable. This paper implements a round and rounded background picture effect.

design sketch:

Implementation method:

1. Initialize a bitmapshader shader shader object; 2. Set the shader object to the brush; 3. Draw circles or rounded corners on the canvas; 4. Use view.setbackgrounddrawable or imageview.setimagedrawable

There are five custom drawable methods that must be overridden. Draw(), setalpha(), setcolorfilter(), getopacity(), and getinternalwidth() and getinternalheight() set wrap in the view_ Content to set the width and height of drawable.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>