如何建立清晰的背景图片为1x1的Andr​​oid部件? [英] How to create crisp background image for 1x1 Android widget?

查看:149
本文介绍了如何建立清晰的背景图片为1x1的Andr​​oid部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个1x1的小部件,也不管我怎么努力,我就不能得到背景图像看漂亮和清晰。我读过几乎所有的资源可以找我,但我还是赢不了。

I'm creating an a 1x1 widget, and no matter what I try, I just can't get the background image looking nice and crisp. I've read just about any resource I can find, yet I still can't win.

我设计的的HTC Desire / Nexus的1,并会爱一个人创造的背景在Photoshop中,什么DPI /高度/宽度时使用(目前使用72/100/80)告诉我。我会担心其他设备的分辨率,一旦我能得到它很好看我的测试设备上的第一次。

I'm designing for the HTC Desire/Nexus 1, and would love someone to tell me when creating the background in Photoshop, what dpi/height/width to use (currently using 72/100/80). I'll worry about other devices resolutions once I can get it looking nice on my test device first.

此外,如果有什么特别的,我需要在投入中的@布局/ main.xml中和Widget_Provider.xml文件。我根本无法找到1x1的小工具的任何实例,因此具备以下条件:

Also, if there's anything special I need to be putting in the @layout/main.xml and Widget_Provider.xml files. I simply can't find any examples for 1x1 gadgets, so have the following:

main.xml中

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="@drawable/background" 
android:layout_gravity="center" 
android:layout_height="wrap_content">

Widget_Provider.xml

Widget_Provider.xml

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="72dip"
android:minHeight="72dip"
android:updatePeriodMillis="6000000"
android:initialLayout="@layout/main"
/>

任何帮助将是很大的AP preciated。

Any help would be greatly appreciated.

推荐答案

您可能想看看谷歌的支持多种屏幕尺寸文件。基本上,这里发生的一切是在Android设备上的显示屏有不同的像素密度。这些被分类为低,中,高(LDPI,MDPI,HDPI)。如果资产不是一个更大的密度的屏幕足够大,则放大到合适的大小 - 这可能是发生了什么事给你。

You may want to have a look at Google's Supporting Multiple Screen Sizes document. Basically what is happening here is that the screens on Android devices have different pixel densities. These are categorized as low, medium, high (ldpi, mdpi, hdpi). If an asset isn't large enough for a larger density screen, it is blown up to the proper size - this is probably what is happening to you.

Nexus One智能手机有一个DPI地方约250,把它放入华电国际一流。使用的谷歌式(单元数* 74) - 2来计算DP为您的1x1的小部件就会使部件尺寸的72x72 DP

The Nexus One has a DPI somewhere around 250 which puts it into the hdpi class. Using the google formula of (number of cells * 74) - 2 to calculate dp for your 1x1 widget would make the widget dimensions 72x72 dp.

从DP到像素的转换:

pixels = dp * (density / 160)

因此​​,对于一个的72x72 DP图像,基于密度相应的图像尺寸是:

So for a 72x72 dp image, the corresponding image sizes based on density would be:

ldpi  (120 DPI) = 72 * (120 / 160) == 54 x 54 pixels
mdpi  (160 DPI) = 72 * (160 / 160) == 72 x 72 pixels
hdpi  (240 DPI) = 72 * (240 / 160) == 108 x 108 pixels
xhdpi (320 DPI) = 72 * (320 / 160) == 144 x 144 pixels

使用这些公式来创建你的资产,你应该得到清晰的图像。

Use these formulas to create your assets and you should get crisp images.

这篇关于如何建立清晰的背景图片为1x1的Andr​​oid部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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