简体   繁体   中英

How can I add margin to background bitmap on Android

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"

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

在此处输入图像描述

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

在此处输入图像描述

But just a:

在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM