简体   繁体   English

Android多屏背景

[英]Android Multi screen background

I'm trying to set the 9 patch image attached below as my layouts background.It looks good on few device backgrounds and few devices shows consecutive circles in center which makes the UI inconsistent. 我正在尝试将下面的9个补丁图像设置为布局背景,在少数设备背景上看起来不错,并且很少有设备在中心显示连续的圆圈,这导致UI不一致。 I want consistent over all the device densities. 我希望所有设备密度保持一致。 How can I achieve the UI appearance on all devices being consistent? 如何使所有设备上的UI外观保持一致?

在此处输入图片说明

很难理解您的意思。语法有点不清楚。您是否对所有版面使用相同的背景?

Make sure you create versions of the 9Patch png for each density and put them in the relevant drawable folders (drawable-mdpi, drawable-hdpi, drawable-xhdpi etc). 确保为每种密度创建9Patch png版本,并将它们放在相关的可绘制文件夹(drawable-mdpi,drawable-hdpi,drawable-xhdpi等)中。

When you run your app, android determines the screen density of the device you're running it on and then looks in that particular drawable folder for your 9Patch png. 当您运行应用程序时,android将确定您正在运行其的设备的屏幕密度,然后在该特定的drawable文件夹中查找9Patch png。 If it can't find a 9Patch png in the folder for that density, it will look in the folders for the other densities until it does find one. 如果在该密度的文件夹中找不到9Patch png,它将在文件夹中查找其他密度,直到找到一个。 It will then either stretch or compress the png as needed to try and create a suitable png for the missing density. 然后,它将根据需要拉伸或压缩png,以尝试为丢失的密度创建合适的png。 This stretching and compressing can lead to the sort of artifacts you are seeing. 这种拉伸和压缩会导致您看到的伪像。

For best results, don't leave it up to the operating system to try and generate images for missing screen densities. 为了获得最佳效果,请不要让操作系统尝试为缺少屏幕密度而生成图像。 Provide your own images for each density. 为每种密度提供自己的图像。

Below is an excerpt from Supporting Different Screens on the Android Developers site. 以下是Android开发者网站上支持不同屏幕的摘录。 Take the time to read and understand this if you want to progress with developing apps for android, because this is fundamental to designing the look of any UI. 如果您想继续开发适用于Android的应用程序,请花些时间阅读和理解此内容,因为这是设计任何UI外观的基础。

"..you should start with your raw resource in vector format and generate the images for each density using the following size scale: “ ..您应从矢量格式的原始资源开始,并使用以下尺寸比例为每种密度生成图像:

xhdpi: 2.0 xhdpi:2.0
hdpi: 1.5 hdpi:1.5
mdpi: 1.0 (baseline) mdpi:1.0(基准)
ldpi: 0.75 ldpi:0.75

This means that if you generate a 200x200 image for xhdpi devices, you should generate the same resource in 150x150 for hdpi, 100x100 for mdpi, and 75x75 for ldpi devices." 这意味着,如果为xhdpi设备生成200x200的图像,则应以150x150的hdpi,100x100的mdpi和75x75的ldpi设备生成相同的资源。”

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

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