0

I am making an app in Android Studio and I have just started making the splash screen. However, I have been having trouble making the image show up as the right size/quality in the android:background property.

Here is the XML code that I am using to display the drawable:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@drawable/main_logo"
    android:keepScreenOn="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    tools:context=".Splash">
</RelativeLayout>

The drawable is displayed, but it is a small image in the top left corner of the screen. The original image is 2500 x 2500 pixels at 9999.99 pixels/inch resolution, so it would have no trouble resizing.

How would I specify to use a different size like xxhdpi instead of hdpi which has been resized, or use the original image and resize it in the center of the screen?

Andrew T.
  • 4,701
  • 8
  • 43
  • 62
NattyMan0007
  • 103
  • 13

1 Answers1

0

You have to actually provide separate resources for each folder - mdpi, hdpi, xhdpi ... The system chooses the best to use based on the specific device. If only a single resource is provided for all situations, it will be used by default and you, or your client, will likely not like the results.

See Supporting Multiple Screen Sizes for more information.

ChiefTwoPencils
  • 13,548
  • 8
  • 49
  • 75
  • Android Studio added a resized version for each folder but there are multiple folders that I don't remember putting there (with -v9 and -v11 after the name) – NattyMan0007 Sep 09 '14 at 00:37
  • so there is an image in hdpi, mdpi, xhdpi and xxhdpi – NattyMan0007 Sep 09 '14 at 00:38
  • @NattyMan0007, but they aren't displaying correctly? Stupid question -> they aren't the same size though right? – ChiefTwoPencils Sep 09 '14 at 00:48
  • No they're not all the same size...Android Studio resized them all – NattyMan0007 Sep 09 '14 at 00:53
  • the original image is 25MB and 2500 by 2500 pixels at max resolution but android studio resized it multiple times and put them in folders. If possible could I not use a drawable and use the 25MB image and just resi it? – NattyMan0007 Sep 09 '14 at 00:55
  • You can; you're resizing the ImageView and not the image itself when doing so. You need to get the screen size (width and height) and use those values to compute the right size. @NattyMan0007. Can you point me to some info on auto-generated images; this is the first I've heard of it being possible. – ChiefTwoPencils Sep 09 '14 at 01:03
  • All i did in Android studio is I went to the res folder and right clicked on it. Then I went to, New -> Image Asset -> and selected the type as Launcher Icon so it doesn't convert it to another image, then selected the the filepath, renamed it and let Android Studio do the rest – NattyMan0007 Sep 09 '14 at 01:52
  • I just read this [post](http://stackoverflow.com/questions/17049732/creating-a-new-icon-set-in-android-studio) and it turns out that that function is for creating Icon sets for the launcher. I am setting the android:background property and not using an ImageView – NattyMan0007 Sep 09 '14 at 01:54