How can I add margin to background bitmap on Android

Viewed 99

So I would like to create a checkered effect with my bitmap. So I am using this very small pixel grey color png. I need to add a margin or padding before it's repeated but I'm unsure how to do this. Any help will be welcome as I have just started learning Android development.

What it's doing right now is repeating the entire image, filling the window with one color.

Background.xml

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/bg"
    android:tilemode="repeat">

</bitmap>

In my Activity Main XML I'm including the above XML

android:background="@drawable/background"
1 Answers

If I understand You correct and You want to make an effect like this

enter image description here

Using a single grey pixel and adding margin to next before repeating, it will be much easier if You don't use:

enter image description here

But just a:

enter image description here

With a pattern like this, You can repeat an image and You will get a checkered effect.

Related