为什么图标/图像在平板电脑上看起来模糊(不清楚),但在Android手机上看起来很好? [英] Why the icons / images looks blur (not clear) on tablet , but looks fine on phone in android?

查看:929
本文介绍了为什么图标/图像在平板电脑上看起来模糊(不清楚),但在Android手机上看起来很好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当时正在开发基于手机的android应用.但是,最近该应用需要支持平板电脑.

I was working on android app based on phone. However, recently the app need to support the tablet.

设计基于1920 * 1080,我将所有图像/图标放入xxhdpi文件夹中,为了降低分辨率,我只让android帮助我重新缩放它.

The design was based on 1920 * 1080, I put all images/ icons into the xxhdpi folder and for lower resolution I just let android to help me rescale it.

问题是,它在手机(1280 * 800 5)上运行良好,但是当我使用平板电脑进行检查时(例如,银河选项卡2,其分辨率仅为1280 * 800 10.1"和1024 * 600),但是看起来很模糊.如何解决?感谢您的帮助.

The problem is , it works well on phone(1280 * 800 5"), but when I use tablet to check it (say , galaxy tab 2 which resolution is only 1280 * 800 10.1" and 1024 * 600) but it looks like very blur . How to fix it ? Thanks for helping.

已添加

<supports-screens 
    android:resizeable="true"
    android:smallScreens="true" 
    android:largeScreens="true"
    android:xlargeScreens="true"  
    android:normalScreens="true" 
    android:anyDensity="true"/>

已经但仍然相同

更新:我还发现平板电脑的dp太小了

Update: I also find that the dp is too small for the tablet

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
        <!-- API 11 theme customizations can go here. -->
        <item name="android:actionBarSize">60dp</item>
    </style>

我使用的是自定义的actionBarSize,它在手机上效果很好,但是60dp对于平板电脑来说太小了,我该如何解决呢?谢谢

I was using a custom actionBarSize , it works nice on phone, but the 60dp is too small for tablet, how can I fix it as well? Thanks

推荐答案

好吧,我认为您在使用图像时不遵循准则. android文档在处理图像时没有说明屏幕分辨率,而是在引用图像资源(通常为可绘制对象)时关注像素密度,这是

Well, I don't think you following the guidelines when you're using images. The android documentation doesn't say anything about screen resolutions when dealing with images, it rather focuses on pixel density when referring image resources (usually drawables) which is explained here. Remember that you can have two types of images (as far as I know):

  1. 图像资源(通常为可绘制对象)
  2. 图像资产

使用可绘制对象时,您必须关注像素密度而不是屏幕分辨率,因为您刚刚发现小型(或常规)屏幕设备的分辨率可能与大型屏幕设备完全相同,有时甚至是普通的屏幕设备(手机)可以比大屏幕设备(平板电脑)具有更高的分辨率,在这种情况下,手机显然具有更高的像素密度.因此,您需要遵循他们的指导原则,以中等像素密度(mdpi)的设备为基准来设计图像资源,如下所示...以96px的图像为例...

When using drawables you have to focus on pixel density rather than screen resolution because as you have just found out a small (or regular) screen device can have exactly the same resolution as a large screen device, to top it off, sometimes a normal screen device (handset) can have a higher resolution than a large screen device (tablet) where obviously in this case the handset has a much higher pixel density. So, you need to follow their guidelines take a medium pixel density (mdpi) device as the baseline to design your image resources as follows...taking a 96px image as an example...

  • 对于中等密度设备(mdpi),在drawable文件夹中提供96px的图像...这是您的基线
  • 然后,通过将基线图像乘以1.5来定位高像素密度(hdpi)的设备...即96x1.5 = 144px ...将该图像放置在drawable-hdpi文件夹中,并使用完全相同的名称
  • 放大倍数为x的像素密度设备图像将是基线图像乘以2(96x2 = 192px).它位于drawable-xhdpi文件夹
  • 对于xx像素大像素密度(xxhdpi)的设备,将基线图像乘以3(96x3 = 288),并将其放置在drawable-xxhdpi文件夹中
  • for a medium density device (mdpi) provide an image with 96px in the drawable folder...this is your baseline
  • then, target a high pixel density(hdpi) device by multiplying your baseline image by 1.5...that is, 96x1.5 = 144px...place this image inside the drawable-hdpi folder with exactly the same name
  • a x-large pixel density device image would be the baseline image multiplied by 2 (96x2=192px). This goes inside the drawable-xhdpi folder
  • for an xx-large picel density (xxhdpi) device multiply the baseline image by 3 (96x3=288) and place it inside the drawable-xxhdpi folder

该链接中的通知是您不需要为像素密度较低的设备提供图片,因为Android会将其从mdpi缩小到没有任何问题...

Notice in the link provided that you don't need to provide an image for a device with a low pixel density since Android scales it down from mdpi without any problems...

注意:Android还支持低密度(LDPI)屏幕,但是您通常不需要创建此尺寸的自定义资产,因为Android有效地将HDPI资产按比例缩小了1/2以符合预期的尺寸.

Note: Android also supports low-density (LDPI) screens, but you normally don't need to create custom assets at this size because Android effectively down-scales your HDPI assets by 1/2 to match the expected size.

在您的情况下,发生的事情是您的Galaxy平板电脑具有较低的像素密度,而Android将图像的尺寸从xxhdpi缩小到了平板电脑具有的任何密度(hdpi或xhdpi)....因此,您的图像是对于512px的图像,Android会将其xhdpi缩小为341px,对于hdpi设备则缩小为256px.

In your case, whats happening is that your Galaxy tablet has a lower pixel density and Android down-scales the image from a xxhdpi to whatever density the tablet has (hdpi or xhdpi)....so, it your image is a 512px image Android would down-scale it to 341px for xhdpi or 256px for an hdpi device.

如果您遵循这些准则并专注于像素密度,那应该没问题.但是,对于assets文件夹中的图像,除了使用可拉伸9补丁图片

If you follow these guidelines and focus on pixel density, you should be fine. However, for images in the assets folder there's no much you can do apart from using the ScaleType enum or using stretchable 9-patch images

希望这会有所帮助

实际上,根据此链接,Galaxy Tab 2具有mdpi屏幕,这意味着您的图像将比xxhdpi缩小三倍.您应该在相应的drawable-x文件夹中提供具有不同大小的相同图像

Actually, according to this link, the Galaxy Tab 2 has mdpi screen, which means your image will be scale down three times from xxhdpi. You should provide the same images with different sizes inside the appropriate drawable-x folders

这篇关于为什么图标/图像在平板电脑上看起来模糊(不清楚),但在Android手机上看起来很好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆