Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: how to align 2 images on a splash screen

I would like to use a splah screen containing 2 images:

  • the main image must be fully center
  • the secondary image must be center between the bottom and the main image

The expected render is something like this: expected splash

But I don't see how to get this, and my second image is bottom aligned: actual splash

The XML of my splash is:

 <?xml version="1.0" encoding="utf-8" ?>
 <layer-list
    xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape android:shape="rectangle">
                <solid android:color="@color/ComplementColor" />
                <padding 
                    android:left="0dip" 
                    android:top="0dip"
                    android:right="0dip" 
                    android:bottom="0dip" />
            </shape>
        </item>
        <item>
            <bitmap android:src="@drawable/main_logo"
               android:gravity="center" />
        </item>
        <item>
            <bitmap android:src="@drawable/secondary_logo"
               android:gravity="bottom" />
        </item>
</layer-list>
like image 989
Gold.strike Avatar asked Sep 15 '17 18:09

Gold.strike


2 Answers

I've finally choose another solution close to that suggested by @Leonardo Cavazzani.

I've added a margin to the bottom image like this:

<?xml version="1.0" encoding="utf-8" ?>
  <layer-list
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
      <shape android:shape="rectangle">
        <solid android:color="@color/ComplementColor" />
          <padding 
            android:left="0dip" 
            android:top="0dip"
            android:right="0dip" 
            android:bottom="0dip" />
      </shape>
    </item>
    <item>
      <bitmap android:src="@drawable/main_logo"
              android:gravity="center" />
    </item>
    <item
      android:bottom="40dp">
      <bitmap android:src="@drawable/secondary_logo"
              android:gravity="bottom" />
     </item>
  </layer-list>
like image 67
Gold.strike Avatar answered Oct 15 '22 05:10

Gold.strike


Set a marginBottom for your bitmap

<bitmap android:src="@drawable/secondary_logo"
                android:gravity="bottom"
                android:layout_marginBottom="100dp" />
like image 43
Leonardo Cavazzani Avatar answered Oct 15 '22 06:10

Leonardo Cavazzani