background image with multi screen - android

I have different folders with different background images for every screen size, also i have created folders for the layouts, the content in each folder is copy & paste (the layout ones) cause i want it to look the same but take the matching pictures for the density.
I don't know why but the application looks great on my phone and very bad on my tablet (background pictures are blurred)

Related

How to make my android game fit to all screen resolution?

I wanted to create a small game on android and then I realize that there is a problem with a screen resolution. I don't know how to make my game's control (Buttons, Textview, etc) will look good to all the screen resolution like (tablet and normal android device) that have different pixel. Like if I design layout for android phone and then if I run it on tablet then buttons, or any controls will look small. So the question is that how to make it (all controls) look more fit and good for any different pixel or resolution device?
You have to create seperate layouts for phablets tablets etc. create 5 folders under res directory.
layout-ldpi
layout-hdpi
layout-mdpi
layout-xdpi
layout-xxdpi
Then copy your file which by default in your layout folder and paste it in a all above folders. Then you have toh manually set the contents for different views . It is a very very boring tedious task

How does Android Studio handle image sizes?

I have an application where I use background images.
I don´t want my images to be stretched or deformed when I run my application on different screens with different ratios.
I already have different images for different screen sizes.
Can someone please explain to me how Android Studio handles the image sizes.
How can I make it that the image isn´t streched, but a sector that fits the screen is being displayed?
Android System uses resource qualifiers/filters to load different resources based on current screen configuration.
Now you have different images for different screen sizes, Good!!
the Folder structure would be something like this.
res
-drawable-mdpi
-drawable-hdpi
-drawable-xhdpi
-drawable-xxhdpi
Now when you run your Application on a device with mdpi screen, android loads images which are under drawable-mdpi folder, and when you run your application on a device with screen density of xhdpi android loads images from drawable-xhdpi folder.
Instead of setting the image as a background for my layout I created an image view. There I set the scale Type to centerCrop and it had the wanted effect!

Android, my app looks good on vertical screens, but size is all distorted on tablets (wide screen)

When my android app gets drawn on a tablet or a emulator that has a wide screen (wasvga,wxcage800 and my tablet) it draws the graphic images from the drawblw-ldpi folder (low res) instead of the drawl-hdpi folder. I'm curtly using a bitmap button. They are all very small (since the smallest image is being drawn) on the tables, but the correct image gets drawn on all the vertical screens.
Why is this????
Is there a way to fix it????
The default folder is the mdpi folder. If another folder doesn't exist, or doesn't have your image, android gets it from drawable-mdpi. Put your images there, and let us know if it works.

Android: Different image based upon screen size

Is there a way to have Android select a different image based upon the screen size? According to the docs and my testing, images must be placed in folders like drawable, drawable-mdpi, drawable-hdpi, etc.
These folders however relate to the screen dpi and not the screen size. The layout folders are used to handle different screen sizes but they don't allow you to store images in them. Only xml files.
So if I run my app on two devices with the same dpi but with different screen sizes, the same image gets selected from the same drawable folder. What I really want is for a larger image to be selected for the larger screen and a smaller image for a smaller screen.
Thanks for your help.
Yea, you are right, this is how works Android, by saving different pictures in particular folders (l,m,h and xh -dpi).
Where is your problem?
You want to keep images for all screen resolutions? Its too many of them.
Can you write more specific what you want achieve?
If you have a problem in layouts.xml, just check:
android:scaleType="..."
You can use 9-patch images. A 9-patch image can be stretched without loosing quality. You may refer to the following link for more information http://developer.android.com/guide/developing/tools/draw9patch.html

selecting image from specific drawable folder in android

I have a Gallery widget that allows a user to select from a variety of images which I supply with the app. Because of different screen resolutions, I have different size images in different drawable folders. Eg drawable-large has 1280x800 versions of the images, drawable normal has 480x320. This is so the image looks good once selected on all resolutions.
The problem I am having is that the Gallery widget, on large resolutions, ends up using the 1280x800 versions of the images to populate the widget. With around 6 of these images, the VM heap memory becomes too large and the app stops working.
Is there any way to force loading images from a specific drawable folder?
I know I could easily solve the problem by adding extra images to my folders but I don't want to increase the size of my app too much.
You can create aliases to your resources, see http://developer.android.com/guide/topics/resources/providing-resources.html#AliasResources
You can then put all your gallery image that are used by multiple resolution in one place, so as to not have resource duplicate in your folders.

Categories

Resources