Hollowing Out Views

Taku Semba
Aug 8, 2017 · 2 min read

Canvas is always the best way of creating any shape of views like circles, rectangles or etc…It also can be used to crop bitmaps to your desired shapes. However, what would you do when you want to hollow out views.

In this articles, I’m gonna share few tips to hollow out views using canvas.

Let’s draw a view normally

First, this is the simplest way of drawing a black circle with Canvas in Android.

The output would be like this below.

Let’s hollow out a view

Finally, let’s do the thing we want to. The code below is how it will be done.

There you go.

Recently, I created a library called “Spotlight” using the hollowing implementation that I explained in this article. please check this out, and it would be really appreciated if you give me a star!

Enjoy hollowing out views ;)

Taku Semba

Written by

Android Engineer at AbemaTV Github: https://github.com/takusemba

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade