简体   繁体   English

如何为多种屏幕尺寸设置图像-Android

[英]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 就像在http://android-ui-utils.googlecode.com/hg/asset-studio/dist/nine-patches.html中上传了500px图片之后,它为我提供了每个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. http://developer.android.com/guide/practices/screens_support.html跳至表1所示的部分。配置限定符使您可以为不同的屏幕配置提供特殊的资源。

Just copy your layout xml to your new layout folders... Then edit the xml to appear how you want for for each layout. 只需将布局xml复制到新的布局文件夹中,然后编辑xml,以显示每个布局所需的样式。

Here is an example of changes made to the manifest. 这是对清单进行更改的示例。 View here: http://developer.android.com/guide/topics/manifest/supports-screens-element.html 在这里查看: 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. 如果您在使用9patch文件或其他方法时遇到问题,这是一种解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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