0

I am coding a splashscreen. My app must work with tablet and phones so my splashcreen is a landscape. On phones, the image's ratio is changed. How can I crop the left and right border while centering the image ?

This is my code :

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
                <bitmap android:src="@drawable/background" 
                android:gravity="fill_vertical|center_horizontal"/>
        </item>
    </selector>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
R1's
  • 41
  • 7
  • I think you need to create a new bitmap as center crop unless you use ImageView with src tag . Look into [This thread](https://stackoverflow.com/questions/6908604/android-crop-center-of-bitmap). – ADM Jan 20 '18 at 16:04

1 Answers1

0

Add this line in the selector:

<item name="android:scaleType">centerCrop</item>