i want to restrict the repeat pattern of a set of random small pattern's to a particular region. I am creating one object ( CustomView ) by using canvas, I have knowledge how to repeat a pattern on the layout using xml code.
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/patterntwo"
android:tileMode="repeat" />
this is not working for canvas.
I essentially want to use a bitmap as a background image for customview and would like to repeat the bitmap in both the X and Y directions of view.
look at this image
Please try with this code:-
paint = new Paint(Paint.FILTER_BITMAP_FLAG);
Shader mShader1 = new BitmapShader(bitmap, Shader.TileMode.REPEAT,Shader.TileMode.REPEAT);
paint.setShader(mShader1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With