uzaysan
uzaysan

Reputation: 605

How to make splash logo fitCenter?

I'm trying to make a splash screen for my app. This is my splash drawable:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:drawable="@color/colorRed"/>

    <item>
        <bitmap
            android:gravity="center|fill"
            android:src="@drawable/logoimage"/>
    </item>

</layer-list>

But logoimage is always cropped and disturbed. It doesnt look good. I want to make it like fitCenter option of ImageView scaletype.

How can I do that?

Upvotes: 0

Views: 89

Answers (1)

Xid
Xid

Reputation: 4951

The important thing here is your image.

  1. Ensure you have alternative images for screens of varying pixel densities (mdpi, hdpi, xhdpi, xxhdpi and xxxhdpi). You can read about providing alternative image resources here

  2. Depending on how big/small you want your logo in the splash you will need to have sizes for the images accordingly.

Note: You do not need the fill attribute for gravity. center attribute will do the job

Upvotes: 1

Related Questions