简体   繁体   中英

How to set images for multiple screen sizes - android

I have a gallery as below 在此处输入图片说明

and i have used

hdpi - 752 x 752  
mdpi -502 x 502 
xhpi - 1002 x 1002 
xxhdpi - 1502 x 1502

As in http://android-ui-utils.googlecode.com/hg/asset-studio/dist/nine-patches.html after i uploaded a 500px pic it gave me the pics for each dpi

but when i use a small screen i get it one after the other and a larger screen i get in in a corner with the blocks. as i have used relative layout everything is connected. so how can i adjust all images for all multiple screens sizes?

One way your layout will show up the same on different devices / screens is by making more layout folders.

This way when a large screen is detected it will use the layout large folder. If it is in landscape, the device / app will use the layout land folder etc.. Layout port = layout portrait etc...

You can get more info here.
http://developer.android.com/guide/practices/screens_support.html Jump to the part that says Table 1. Configuration qualifiers that allow you to provide special resources for different screen configurations.

Just copy your layout xml to your new layout folders... Then edit the xml to appear how you want for for each layout.

Here is an example of changes made to the manifest. View here: http://developer.android.com/guide/topics/manifest/supports-screens-element.html

<supports-screens android:resizeable=["true"| "false"]
                  android:smallScreens=["true" | "false"]
                  android:normalScreens=["true" | "false"]
                  android:largeScreens=["true" | "false"]
                  android:xlargeScreens=["true" | "false"]
                  android:anyDensity=["true" | "false"]
                  android:requiresSmallestWidthDp="integer"
                  android:compatibleWidthLimitDp="integer"
                  android:largestWidthLimitDp="integer"/>


<manifest>

If you are having trouble with 9patch files or other method, This is one way to do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM