android - 如何在action bar中显示圆形logo?
PHPz
PHPz 2017-04-17 13:04:01
0
2
619

想实现如上图Google+的action bar,显示圆形logo(指定的drawable)。如何实现?

PHPz
PHPz

学习是最好的投资!

reply all(2)
大家讲道理

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

on Paint

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...


伊谢尔伦
#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;

}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template