Android 安卓壁纸/背景尺寸

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2010399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:11:22  来源:igfitidea点击:

Android wallpaper/background dimensions

androidbackgroundwallpaper

提问by hpique

Which are the default dimension of the Home wallpaper/background for the various Android screen configurations (small, normal and large screens with low, medium and high density)?

对于各种 Android 屏幕配置(低、中、高密度的小屏幕、普通屏幕和大屏幕),首页壁纸/背景的默认尺寸是什么?

Are 9-patch PNG files supported for the wallpaper? Should I be using these instead?

墙纸是否支持 9-patch PNG 文件?我应该改用这些吗?

I found a method in API level 5 that gives you the minimum size of the wallpaper, but I would like to support previous versions of Android as well.

我在 API 级别 5 中找到了一种方法,可以为您提供最小的壁纸尺寸,但我也希望支持以前版本的 Android。

Thanks!

谢谢!

回答by Romain Guy

A wallpaper is twice as wide as the device held in portrait mode. So 960x800 on a Nexus One, 960x854 on a Droid, 640x480 on a G1/Magic/Hero, etc.

墙纸的宽度是纵向模式下设备的两倍。因此,Nexus One 上为 960x800,Droid 上为 960x854,G1/Magic/Hero 上为 640x480,等等。

回答by Christopher Orr

This article on the Android Developers' siteshows the range of screen resolutions for each density.

Android 开发人员网站上的这篇文章显示了每种密度的屏幕分辨率范围。

I believe the wallpapers have to match the screen resolution and are not stretched. You can see this if, for example, you create a new emulator with a high screen density like 480x854. The default home screen background is centred, with large black bands at the top and bottom.

我相信壁纸必须与屏幕分辨率相匹配,并且不会被拉伸。例如,如果您创建一个具有高屏幕密度(如 480x854)的新模拟器,您就会看到这一点。默认主屏幕背景居中,顶部和底部有大黑带。

The WallpaperManagerAPIindicates that you must use a PNG- or JPEG-format image, even if you use the setResource()method — the resource mustbe a Bitmapand so not a nine-patch or other type of Drawable.

WallpaperManagerAPI表示您必须使用PNG-或JPEG格式的图像,即使你使用的setResource()方法-资源必须Bitmap等不九宫或其他类型的Drawable

回答by Renate

Don't guess, ask the WallpaperManager:

不要猜,问问墙纸管理器:

  manager = WallpaperManager.getInstance(this);
  width = manager.getDesiredMinimumWidth();
  height = manager.getDesiredMinimumHeight();