When implementing a splash image which has such a design that image cannot be skewed or cropped if the device screen is of different resolution or size, how to perfectly implement this? Image must be a real full-screen without black background due to different aspect ration.
Shall we create splash image for every device screen size? This is how we do at the moment and it's pretty much work. So we go to Android developer support screen advise page to know what images sizes we need. you see, there are a lot of them.
Is there a better and quicker solution?
just get the splash screen in 1920*1080 and put in xxhdpi android system will auto ajust it
Stretch occurs when when try to fit an image into an image view of different Aspect-Ratio.
Create 2 or 3 images for major Aspect-Ratio and then use android:scaleType="fitXY" on your image view, for devices that uses different aspect-ratio than you specify it won't differ a lot so you don't get a noticeable stretch.
Most common aspect-ratio are:
2:1 // ultra wide ex. 800*400 screen
16:9 // HD wide ex. 1920*1080 , 1208*720 , 720*450
16:10 // wide
4:3 // old tv square-like
If you can prepare a image resolution 1920*1280 and put in drawable-xxhdpi, it would fit to any screen
Try to create a 9-patch image and use it as a background of the splash activity/view/whatever. Put your fixed size logo (or whatever you want to display) in the non-scalable part of the 9-patch and let the other areas stretch to fill the view. Note that the non-scalable area (e.g. your logo) should have size that will fit the smallest display you want to support.
Related
I have a background image in an activity, its size was set to 1280x920, as adviced in Background image crashes android. This works perfectly.
I also have a full screen activity (sticky immersive), with the same configuration, the image is "stretched" out vertically. What should be the size of the image so that there is no scaling or stretching at all? (While the image occupies the full screen, off course)
It depends on screen. Android supports multiple screens. That's way in project we have x-hdpi, hdpi, xx-hdpi folder. As source:
https://developer.android.com/guide/practices/screens_support.html
https://developer.android.com/training/multiscreen/screensizes.html
There is no one size. Every Android device has different screen sizes. What you need to do instead is provide multiple sizes and accept some stretching or shrinking on odd sized devices. See https://developer.android.com/guide/practices/screens_support.html for more advice.
I am creating an app for different devices and I added images with different sizes in drawable-small, drawable-medium... to add the same image for different devices but I need to increase the size of the image when the size of the screen increases is this the correct way?
plus I need to increase the font size when the screen size increases how can I do that and if I used the layout-small... folders what font size will be the perfect size for the devices with small screen size (portrait and landscape) and for the medium and large..?where can I find this info as I am trying and trying different font sizes but there must be another way!!
thanks.
This is a very rookie question but here goes:
You set the text and image sized in dp (density pixels) so screen size and resolution is irrelevant.
As for making multiple drawables for each screen size is a good idea but not a necessity since you can choose how much of the screen each picture will take, but on bigger screens make sure the resolution of your images are high enough to look good.
For scaling a particular image to all screen size you can use nine patch image. There will be drawninepatch.bat file in the tools folder of your sdk. Open that , drag and drop the image , and you want to expand the image based on your needs. Now after the nine patch is created put that in the drawable folder. This image will expand accordingto the screen resolution and densities.
What is the applications screen size without the status bar and softkeys(in some phones)?
Like for Example i know:
320X480 trimmed down to 320X455 which is the basesize.
but what about others , i have done many calculations and a lot of searches online to figure out a defined size for other screen but i seems can't, Also While applying the formula *.75 ldpi, *1.5 hdpi, *2.25 xhdpi to get other screen, it doesn't add up.
Like 320X480 is mdpi to get the hdpi do *1.5 and you will get 480X720 which is not the situation for devices out their ! and using this method my application images where stretched, this method is according to the Google documentation, i'm confused as hell.
I have tried to et sizes using the emulator also it was very different! for height.
So if the problem is with height only, i'm thinking creating background as patterns and then work only on the width of the screen size and re-size every other elements to screen width only like 240px, 320px, 480px, 720px and also consider the size of them to fit minimum height.
I believe it's not possible to define a height for android which will go like generic because of the variety of android devices.
So what do you think about this approach to use background as pattern and forget about every device on earth height ?
you can use tile pattern, create a small texture and then make it tileable drawable in xml, so it will be tiled across screen, or the second might be using 9-patch images, in that way you can select which area of the image scale and which area to not scale, so they will be scaled according to that way.
I have a problem with supporting different screen sizes. My application has different drawables for mdpi (320x480), hdpi (480x800) or ldpi (240x432). I also have different layout for small, normal-notlong, normal-long. Every size scaling or placement features are done in dp. However my problem is that I need to precisely place an element on the screen so it will perfectly fit to the background. One example here is an image that I download and show inside a frame that is part of the background. Or I also draw a circle (using drawArc) on the top of an imageview object and need to place it precisely to fit a 'black hole' that is on that image. Because the position is dependent on the background I place the elements with parent margins. As I wrote I am using dp for that. However If I fit my setting for a 320x480 3" screen and then change to 3.1" the elements are slightly misplaced and don't fit the background. The same if I have 480x800 3.5" device but change to 3.6" - the elements are misplaced slightly but that is enaught to look poorly in the design. What can I do about it? I am sure there has to be a way to achieve this on any screen size - i.e. games must use some kind of that mechanism and they work on any screen size. Can any one help?
I'm creating a splash screen that will display while my Android application loads. I'd like to create it at the correct size so Android won't auto-scale it up or down to fit the screen. (It's a bitmap image, a photograph of an oil painting, so I can't just turn it into a nine-patch.)
But there are at least three important screen sizes I care about: 320x480, 480x854 (Droid), and 480x800 (Nexus One).
I've read the documentation on supporting multiple screen sizes, but I still don't see how I'm supposed to configure different splash screens for Droid/Nexus one (they're both "hdpi" resources as far as Android is concerned), and I don't know exactly how large my splash screen should be in any case. (How tall is the OS title bar/menu in Droid? N1?)
What size should I make these images, and how do I tell Android to use the correct size on a given screen?
You don't need to worry about the absolute screen size or status bars or anything — that's why we have nine-patch images.
What I did was have an image that looked good for each resolution — essentially a logo on a transparent background, with some text at the bottom.
Then I chopped off quite a lot of space at the top and side edges, made a nine-patch border round the image, with a single pixel near the left, right and top edges. This allows the image to expand evenly at the sides and top to fill the screen.
Edit, in response to Dan's comment below:
Yes, there is a way to determine which graphics should be used for which explicit screen sizes, but it's deprecated.
Just as there are drawable-hdpi and -ldpi resource qualifiers, it's also possible to use drawable-HHHxWWW — the larger pixel dimension coming first.
e.g. drawable-800x480 and drawable-854x480
Okay, firstly: you can find the device model via android.os.Build and use that to determine which image to show.
Secondly, I personally wouldn't bother. Layouts should be done in dip since every android screen is 320x480 dip I believe, and android maintains aspect ratio among devices very well through this in my experience. A 480x800 splash set to fill parent has been pretty reliable on both N1 and the droid as far as I have encountered.
Another solution that I implemented is to put an ImageView that fills the screen (width and height both "MATCH_PARENT") with scale type "centerCrop". This way, the image is not stretched but cropped along the edges. Try not to put important content (logos and stuff like that) close to the edges. If it is a photograph, I hope that the edges are "expendable" and can be cropped out.