Android - How to create a rounded view and background from a tiled image?

I am trying to create a view in Android that has rounded corners and also uses a background with a tiled image (and which appears on top of another view with a mosaic background).

I can create a shape suitable for corners and a bitmap designed for a tiled image, but I don’t see how I can apply them to one view.

Some things I tried:

  • Nesting a view with a tiled background inside a view with rounded corners - does not work, the tiled background just appears on top with square corners

  • Paint on the corners of the view with rounded corners - this does not work due to the tiled background below (otherwise it will work fine)

+7
source share
2 answers

I believe that your custom view should define the drawing area using Path. Then you can draw a Path with paint and a shader, doing what you want (fill and tile).

http://developer.android.com/reference/android/graphics/Path.html

+2
source

You can check out the video , which contains a way to do this, without using clipPath , which is not supported by hardware acceleration.

+1
source

All Articles