How to repeat a pattern in the Custom view up-to boundaries?
android, canvas, design-patterns
Solution
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);
Problem
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