• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Different screens resolution optimization

 
Tasos Sim
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have read Android Supporting Multiple Screens but may was something i didn't get.
I created a background image for each drawable folder: 240x320 in drawable-ldpi folder, 320x480 in drawable-mdpi, 480x800 in drawable-hdpi, 640x960 in drawable-xhdpi and 1200x1920 in drawable-xxhpdi.

There are 3 images attached to show you...
The app displays well on the below screens (using emulator):

768x1280 xhdpi - 4.7''
480x800 hdpi - 4.0''
240x432 ldpi - 3.4''
1080x1920 xxhdpi - 4.95'' (Nexus 5) and
320x480 mdpi - 3.2''

("Displaying well" image)


It does not look well on:

480x800 mdpi - 5.1'' and
1200x1920 xhdpi - 7'' as it has too much space in the middle down to the bottom of the image.

("Too much space on the bottom" image)

and also on
240x320 ldpi - 2.7'' the button nearest to the bottom is almost cropped as it is appeared down on the bottom of the screen.
("Almost cropped!" image)

Note that the background image displays well. I've put layout_width="230dp" and layout_height="50dp" for the button.

Plase help me on this!
normal.jpg
[Thumbnail for normal.jpg]
Displaying well
med large.jpg
[Thumbnail for med large.jpg]
Too much space on the bottom
small.jpg
[Thumbnail for small.jpg]
Almost cropped!
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't a problem with your background image, it is a problem with your layout. For tablets and large screens, or really small screens it is often best to have dedicated layouts which make better use of the space. For example, it rarely is right to just spread out the same content you display on a phone screen so that it fills a 7" tablet. Rather, you would find some portion of the view which should grow and give that a proportional amount of more space (an image for example) or you combine layouts so there is less navigation needed (which is what Fragments help with).

Similarly, for really small screens you can't just shrink the views to fit on the screen you have, you will need to redo the layout so the touch targets are touchable and the text is readable - and this, too, often means re-thinking the navigation (maybe split a single view with a lot of information into two, or adding a ScrollView).
 
Tasos Sim
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply!
It's strange that 480x800 mdpi doesn't display well while 480x800 hdpi does.
I am new on Android but i have read a lot about screen optimization...BUT i don't understand about how configure the layout.
Please if you could give me an example or something to understand...

On my res/layout folder there are only activity_main.xml and fragment_main.xml files. What do i have to do?
Thanks in advance


EDIT:
So i have to create inside "res" new folders like "layout-hdpi" etc?

And then what...? I mean i'll create a new XML file,right?
It will be the same fragment_main.XML (with the same name) that will contain what exactly contains the main file and just change the text or whatever may matters??


P.S: I've already create an XML file (only in drawable-hdpi) for the button so when it's "clicked" to appear another image... I didn't create for other folders too cause
i've create the image(button) in different resolution and in the apropriate folder...
The point is that although i have made the 2 images in different resolutions and in the relative folder, the button displays as before...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic