0

This is my splash screen activity which then directs to my main activity

 public class SplashScreenActivity extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            startActivity(new Intent(SplashScreenActivity.this, MainActivity.class));
            finish();
        }
    }

Below is my splash screen xml file

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:opacity="opaque">
    <item android:drawable="@android:color/holo_purple" />
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/blogger"
            />
    </item>
</layer-list>

I tried changing the gravity attributes but nothing changed.Below screenshot is the stretched image

enter image description here

Swayangjit
  • 1,875
  • 2
  • 13
  • 22
yatso1
  • 21
  • 8

1 Answers1

0

Only API 23 or later

Just use

<item
    android:width="200dp"
    android:height="200dp"
    android:drawable="@drawable/splash_background"
    android:gravity="center" />

instead

<item
    android:left="200dp"
    android:right="200dp">

    <bitmap
        android:src="@drawable/splash_background"
        android:gravity="center" />

</item>

Or Use ImageView

<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="center"
android:src="@drawable/Icon" />
Usama Altaf
  • 90
  • 1
  • 4
  • 23
  • I am using API 23 + and I am implementing my splash screen the appropriate way. Also, my bitmap has different sizes xxhpi, hdpi yet still giving me a hard time figuring out a solution. – yatso1 Feb 08 '21 at 20:00