CircleImageView

So I need to make the CirleImageView to be more like a button. And I want this view to show some custom or maybe online image. So FloatActionButton won't be a solution.

I referenced to this issue and come up with a solution:

So to have a elevation, we must have a background, this is my background



    

The background color can't be @android:color/transparent, it will make elevation disappear.
Then set this background to CircleImageView. and set an elevation. But I soon find out that the elevation is partially cut off like this

wrong_cllip

I think that's because the shadow reached the boarder of view
So I added a Layout to wrap around CircleImageView and make it slightly larger than CircleImageView.
So the code looks like this

 

    

78dp
54dp

And this makes CircleImageView have a nice shadow like a FAB. It's even better when I added a ripple animation using this workaround

device-2018-05-17-111412

你可能感兴趣的:(CircleImageView)