Android maintain same proportion for all different screen sizes and resolution

▼魔方 西西 提交于 2019-12-08 13:02:36

问题


I want my application components to look in a scaling mechanism. Means image size must look in proportion with screen size.

I know that to use 4 different drawable folders.

Considering hdpi as base (480 x 800) ratio would be:

mdpi 66.66% hdpi 100% xhdpi 133.33%

however xhdpi size accoring to above ration is 640 x 1060. But samsung s3 screen size is 720 x 1280

So suppose If I have image of 100 x 100 in hdpi, and so 133 x 133 in xhdpi

But after applying above rule, Image in samsung s3 not looking proportionality with screen size as image size is based on xhdpi (133 x 133).

Same problem in hdpi with 480 x 854 screen size. Suppose I have to display images on screen, how to filled up that 54 px gap? as our images are based on 480 x 800 in hdpi folder .

So my question is how can we get smaller image for smaller screen size and bigger image for bigger screen size so that all layout and images looks in proportional with screen size?


回答1:


If you do not compromise not even with a fewer pixels on the screen then it would be ideal for you to use

layout-sw720dp folder for Samsung S3

More info is provided in the official documentation

below are some typical screen widths to be used

res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)

and make your drawable folder like below

xhdpi: 720x1280

large-hdpi: 640x960

hdpi: 480x640

mdpi: 320x480

ldpi: 240x320


来源:https://stackoverflow.com/questions/19172502/android-maintain-same-proportion-for-all-different-screen-sizes-and-resolution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!