How to add a margin top to a bitmap?

725 Views Asked by At

This is the drawable file :

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
  <item>
    <color android:color="#ffffffff"/>
  </item>
  <item>
    <bitmap android:gravity="top|center_horizontal"
            android:src="@drawable/splash_screen"/>
  </item>
</layer-list>

I want the bitmap to have 20px margin-top, I didn't find how to set margin-top to bitmaps element

1

There are 1 best solutions below

0
On BEST ANSWER

You can try with android:top.

The top offset in pixels.

    <item
        android:top="20dp">
         <bitmap android:gravity="top|center_horizontal"
         android:src="@drawable/splash_screen"/>

    </item>