7

I am using theme instead of layout to show splash screen,but I am confused what resolution images to set for different screen densities,because <item> tag's width and height attributes available API>22.

Background drawable

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

    <item android:drawable="@color/colorAccent" />
    <item >
        <bitmap
            android:gravity="center"
            android:src="@drawable/splash_logo" />
    </item>

</layer-list>

Style

  <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@drawable/splash_background</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorPrimary">@color/colorPrimary</item>
    </style>
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
Katy Colins
  • 533
  • 2
  • 8
  • 24

1 Answers1

18

Splash Image size for different resolution devices for portrait

MDPI = 320x480px 

LDPI = 240x360px

HDPI = 480x720px

XHDPI = 640x960px

XXHDPI = 960x1440px

XXXHDPI = 1280x1920px

From https://romannurik.github.io/AndroidAssetStudio/index.html you can make a 9-patch image for all the resolutions - XHDPI,HDPI,MDPI,LDPI

Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
  • Thank you,and is it mandatory to use 9-patch?can i use just image by the resolutions above? – Katy Colins Dec 16 '17 at 11:05
  • yes, you can use your images that is just a suggestion. – Amit Vaghela Dec 16 '17 at 11:08
  • But you know actually my drawable is not full screen image,it is small,like app icon – Katy Colins Dec 16 '17 at 11:12
  • still 5 to go) The minimum is 15) – Katy Colins Dec 16 '17 at 11:14
  • Ok now :D But how sould I calcualte the size for little image for the center – Katy Colins Dec 16 '17 at 11:16
  • not actually. you can generate that size of images and use them – Amit Vaghela Dec 16 '17 at 11:16
  • 1
    `MDPI is 320x480 dp = 320x480px (1x)` **FALSE**. **Density** has nothing to do with **resolution**. mdpi is 160**dp**, not 320x480 **px**. The resolution can be anything (in facts, most tablets are mdpi, with a typical resolution of 1024x600). What counts is that, since at mdpi we can assume 1px = 1dp and we know the relation between densities, we have the formula to calculate the resolution for all screen densities. – Phantômaxx Dec 16 '17 at 11:35
  • @NoiseGenerator you are right but to support diff screen i have given this solution. you can check https://stackoverflow.com/a/34726279/2826147 – Amit Vaghela Dec 16 '17 at 11:42
  • Still it is a false idea that mdpi is necessarily 320x480. See [this](https://stackoverflow.com/questions/6272384/most-popular-screen-sizes-resolutions-on-android-phones). – Phantômaxx Dec 16 '17 at 15:22