I want to make a button like this but I cant
Because when I convert it to 9patch the lines of button is scaling. But i want to repeat and full the button with lines
this is the original image
i want to be like this
But it looks like this :(
I want to make a button like this but I cant
Because when I convert it to 9patch the lines of button is scaling. But i want to repeat and full the button with lines
this is the original image
i want to be like this
But it looks like this :(
Create a Bitmap Resource and repeat texture.
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ab_texture_tile_apptheme"
android:tileMode="repeat" />
You only use 9patch when you scale some part of it. Based from your example image and you quote lines of button is scaling
that is because of the 9patch.
Solution
Dont use 9patch just set it as a background Drawable/imageSource in your desire view
try this:
final float r = 32;
float[] outerRadii = {
r, r, r, r, r, r, r, r
};
ShapeDrawable d = new ShapeDrawable(new RoundRectShape(outerRadii, null, null));
ShaderFactory factory = new ShaderFactory() {
@Override
public Shader resize(int width, int height) {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
Shader shader = new BitmapShader(bitmap, TileMode.REPEAT, TileMode.REPEAT);
Matrix localM = new Matrix();
localM.postRotate(45);
shader.setLocalMatrix(localM);
return shader;
}
};
d.setShaderFactory(factory);
someView.setBackgroundDrawable(d);