lundi 20 juin 2016

How to position bitmap in splash screen

Dears,

I have a square title.png which I show in (also square) TitleFragment on the upper end of the screen in portrait mode (never mind landscape mode). Now I would like to add a splash screen to my app while it is loading. I followed this tutorial and it works fine. My splash.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="@color/dark"/>
    <item>
        <bitmap
            android:gravity="top"
            android:src="@drawable/title"/>
    </item>
</layer-list>

As you can see I am using the same title.png as in TitleFragment, however, I failed at positioning it at the same positition as TitleFragment is showing the image. My titlefragment.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:tools="http://schemas.android.com/tools"
             android:layout_width="match_parent"
             android:layout_height="match_parent">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/title"
        tools:ignore="ContentDescription"/>
</FrameLayout>

mainactivity.xml locates it in the largest possible sqaure at the top of the screen.

My question is: Can I emulate the positioning of the fragment in the splash screen. I would like the title.png in the splash screen and the title.png in the titleFragment to be congruent. I already played with the relevant line in splash.xml (android:gravity="top"), but to no avail.

Aucun commentaire:

Enregistrer un commentaire