Development issue/problem:

I made a screensaver with this tutorial and it works very well:

Basically, I repair the screen using a theme:

I wanted to insert the vector graphic as follows: [drawable_wash screen]

The image is enlarged across the entire screen. For API 23 it works as it should. But on the old machines, it just stretches. I tried the width and height, and even mixed them with points of view, but to no avail.

How can I solve this problem?

Solution 1:

I had the same problem.
Unfortunately it is not possible to run the screensaver with vector display only for pre-API 23.

The problem is that you can’t load VectorDrawableCompatible outside the process, as in this case in your android:windowBackground themes. So what probably happens here is that API 21 converts the vector to PNG for compatibility. This allows you to insert an element into the converted PNG, stretching the pixel card at all edges because an element is missing.

So my solution is this: Create a Drawable_splashscreen.xml file in the Drawables-v23 folder that looks like this for a vector drawing.

Then create another drawable_splashscreen.xml file, but in the usual drawables folder :

Pay attention to the item. Now, when a PNG is used on devices with the pre-installed API 23, it is displayed correctly and does not extend into the background.

Unfortunately you also have to provide a PNG screensaver to work in the old APIs.

But any device with API 23+ uses vector rendering.

Solution 2:

For a full screen of the home screen, try it:

android: gravity=fill_horizontal|fill_vertical

If the resolution is not allowed, the solution may be to create
split images for any resolution size.

The most common resolutions are :

  • Small = 240 x 320px (ldpi)
  • Medium = 320 x 480px (mdpi)
  • Large = 480 x 800px (hdpi)
  • xLarge = 640 x 960px (xhdpi)

Portrait:

  • ldpi = 240 x 360px (0.75 x mdpi)
  • mdpi = 320 x 480px (basic density)
  • Pixel per inch = 480 x 720px (1.5 x mdpi)
  • xhdpi = 640 x 960px (2 x mdpi)
  • xxhdpi = 960 x 1440px (3 x mdpi)
  • xxxhdpi = 1080 x 1920px (4 x mdpi)

Landscape format (inverted portrait format) :

  • ldpi = 360 x 240px (0.75 x mdpi)
  • mdpi = 480 x 320px (basic density)
  • Pixel per inch = 720 x 480px (1.5 x mdpi)
  • xhdpi = 960 x 640px (2 x mdpi)
  • xxhdpi = 1440 x 960px (3 x mdpi)
  • xxxhdpi = 1920 x 1080px (4 x mdpi)

More information can be found here:

  1. https://design.google.com/devices/
  2. The Android screen saver allows you to adjust the screen size for all devices.
  3. http://vinsol.com/blog/2014/11/20/tips-for-designers-from-a-developer/

Solution 3:

An edited solution that makes your SplashScreen look good on all APIs, including API21 to API23.

First read this article and follow the GOOD way to create a screensaver.

If your logo is distorted or doesn’t match and you only focus on the API24+, you can resize your vector image directly in the xml file, like this :

In the code above I changed the size of the drawing I made on a canvas from 640 × 640 to 240 × 240. Then I stick it in my screen saver and it works like a charm:

My code actually only draws the triangle in the image below, but here’s what you can do with it. The resolution is finally excellent, unlike the pixel edges I got with the bitmap. It is therefore absolutely necessary to use vector drawings (there is a website called vectr that I used to make mine without having to download special software).

EDIT to make it work with API21-22-23.

Although the above solution works for devices with API24+, I was very disappointed after installing my application on a device with API22. I noticed that the screen saver tries to fill the whole image again, and it doesn’t look like it. After half a day of plucking my eyebrows, I finally lost the habit of making this decision.

You need to create a second file with the same name as the splash screen xml (for example splash_screen.xml) and put it in 2 folders called drawable-v22 and drawable-v21, which you create in the res/ folder (to see them, you need to change the display of your project from Android to Project). This is to tell your phone that you need to redirect to the files in these folders when the corresponding device runs the API corresponding to the -vXX suffix in the rendered folder. See this link. Place the following code in the list of layers in the splash_screen.xml file you create in these folders:

For some reason you have to wrap your drawing in a bitmap with these APIs in order to work. The problem is that you have to use the extra render-map approach, because the second version of the splash_screen.xml file will ensure that your screensaver will not be displayed at all on devices with an API larger than 23. You may also need to place the first version of splash_screen.xml in drawable-v24 as the default android in the closest drawable-vXX folder it can find for sources.

SplashScreen with Vector stretched full screen –

Solution 4:

I do not think it is possible to do this with vectors, for devices < API 23, because you can not set the android:height android:width attributes for rendering.

To set up my icon-centric screensaver, I had to export my vector logo for each screen format as .png and paste the bitmap into the layer list:

Ideally, I wouldn’t want bitmaps in my sources at all, but at least the splashguard is the only place I should use bitmaps.

Solution No 5:

Use a bitmap image and define your image in src. Adjusting the centre of gravity

SplashScreen with Vector stretched full screen &#8211;

Solution No 6:

Do not add your image to the window:Background, but add it as android:src to display the image for the SplashScreenActivity layout.

Good luck!

android splash screen scale image,android splash screen fill,android:windowbackground center,android launch_background xml,android splash screen aspect ratio,android layer-list bitmap centercrop,android layer-list bitmap size,android layer-list vector,android layer-list text,android layer-list item scale,android:windowbackground scaletype,<bitmap> requires a valid 'src' attribute,beautiful splash screen android,splash screen android github,android splash screen generator,splash screen android kotlin,android splash screen animation,full screen splash screen android,android splash screen keep aspect ratio,android splash screen loading animation,android splash screen guidelines,app splash screen template,splash screen images android,android splash screen smooth transition

You May Also Like

15 Best Online Multiplayer Cricket Games for Android [2021]

Cricket is one of the biggest sports in the world and in…

Average Snowmobile Dimensions: Length, Width, and Height

*I may receive commissions for purchases made through the links in this…

10 Best Laptop for Accounting Students | laptops for quickbooks

As a designer, draftsman or mechanical and structural engineer, you must be…

7 Difference Between Xiaomi and Redmi Phones

Not many people know that Xiaomi started out as a software company.…