2

I'm using the approach described in Creating a Splash Screen. It uses a resource (layer-list) with a background and an image. That is used as windowBackground in a theme and this theme is set on an activity. Now I created all drawable folders and put images of different sizes in there.

Now I have these issues:

  • starting app in landscape on smart phone leads to a black splash screen (on tablet it stays in portrait)
  • images from drawable-land folder are not taken
  • the size of the image should be bigger on some devices

In which resolution should I provide the images? The image should have one third of the width of the display width. How can I manage that?

I tried to use this table as reference and calculating the width by taking one third of portrait size. E.g for HDPI, one third of 480 is 144, but the tablet has a width of 800 (not 480). As consequence the image is too small.

Furthermore I don't think that 9-patch files could help me here. It only describes the enlargement, but then the lowest common denominator would be an image of size LDPI ... Enlargement doesn't work so good for a text logo (custom font).

What are my options?

Edit:

starting app in landscape on smart phone leads to a black splash screen (on tablet it stays in portrait):

Adding a break point and the splash screen is shown instead of a black screen. Building an apk and installing on the smartphones works. Debug mode not.

images from drawable-land folder are not taken

Added ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation) and now they are.

But I still have no clue how to define an image, which does take a certain amount on the screen with this approach. For now I supplied a bigger image (xhdpi into hdpi) ...

Community
  • 1
  • 1
grabner
  • 1,219
  • 3
  • 13
  • 23

1 Answers1

0

you should put those images in mipmap folder not at drawable. You have to crop image into three size hpdi,ldpi and mdpi. These theree are best for any android devices.(Fits for all). If you want to display image in full screen then you can define android:background="@mipmap/image" instead of android:windowBackground="@mipmap/image" . For preventing splahscreen from being landscape you can define screen orientation inside activity like below:

<activity android:name=".Splash_Screen"
 android:screenOrientation="portrait">

If you doesn't know the required resolution for image ldi,hdpi and mdpi then there's question asked on stackoverflow, google it!! Hope it helped and sorry for poor english!!

Queendevelopers
  • 183
  • 3
  • 20
  • Isn't `mipmap` only for the app icon? I don't want to display the image fullscreen. It can be landscape, but then it should take the images from the respective folder (e.g. `drawable-land-hdpi`). The thing with the resolution is that a density (e.g. hdpi) is not a fixed value. Instead it reaches from 480px width to 800px width. Now I could optimize my images for 480px, but then it doesn't suit for 800px. If I adapt it for 800px it doesn't suit for 480px and so on. I could provide a high resolution image and the system should scale it down for me. Is this possible? How? – grabner Aug 25 '16 at 06:31
  • As I am a beginner, I don't know much about it. I use the full screen and move three splash image into hdpi,ldp and mdi inside mipmap folder manually opening file path with right click instead of drawable and it's working fine in any screen. I have already tested in Nexus tab. No, Android won't fit provided images in all screen, if it do then eg hdpi will never be there.. Here's everything explained https://developer.android.com/guide/practices/screens_support.html – Queendevelopers Aug 25 '16 at 07:21
  • I'm currently reading that link :-) In my case I want to use an image, which should take up a certain amount of space. I didn't found a solution for my case. Only the information from *Alternative drawables* is very interesting for choosing a certain icon size. – grabner Aug 25 '16 at 07:53