想实现如上图Google+的action bar,显示圆形logo(指定的drawable)。如何实现?
大家讲道理2017-04-17 13:06:01
If you want to use it, you can directly use the following 2 libraries:
https://github.com/hdodenhof/CircleImageView
https://github.com/vinc3m1/RoundedImageView
In terms of principle...
Just use PorterDuffXfermode
First use the canvas.drawCircle method to draw a circle, then set PorterDuffXfermode to use orthogonal mode,
Draw the bitmap again, so that the two graphics drawn before and after only show the intersection part...the picture will only be a circle..
The second way is Shader
To understand it simply, it can be thought of as making a bitmap into a paint texture, and then using paint to draw a circle directly on the canvas
The above two libraries have source code...
伊谢尔伦2017-04-17 13:06:01
#logo {
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
border:1px solid white;
width: 50px;
height: 50px;
background-image: url('xxx.xx');
background-size: cover;
}