English 中文(简体)
了解DPI,然后通过代码获得它?
原标题:Android: Understanding the DPI and getting it via code?

有谁能帮上忙吗? 我发现很难得到心智、心智、心智的DPI,

例如,它说明密度如下(取自和机器人 docs)

ldpi    Resources for low-density (ldpi) screens (~120dpi).
mdpi    Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
hdpi    Resources for high-density (hdpi) screens (~240dpi).
xhdpi   Resources for extra high-density (xhdpi) screens (~320dpi).

但为什么它只表示~240dpi, 即一个值? 它不应该是(例如)移动(samsung星系S2)是WVGA (800 x 480) (DPI),符号~是什么意思?

举例来说 800 x 480 (一个萨姆星系 2 的 dpi) 如何转换成上面的值之一?

我想知道,如果有人能帮我 精神上理解这一点。

稍后能否通过代码获取密度大小, DPI(包括 x 和 Y) 通过代码获取?

我有点迷路了

最佳回答

但为什么它只有一个 ~ 240dpi, 即一个值呢?

你当时在等什么?

符号是什么意思?

正如评论者指出的,这意味着“约”。 事实上,设备制造商会选择他们想要的设备装在哪个密度桶里, 通常是根据他们用真实世界应用程序的行为进行的测试。 “ 一般来说, < / em>, 他们会选择最接近其实际屏幕密度的密度桶, 但这并不保证。 ”

举例来说 800 x 480 (一个萨姆星系 2 的 dpi) 如何转换成上面的值之一?

您没有。 分辨率不是密度。 我可以用一个800x480 显示, 显示为1mm、 1cm、 1m 或 1km 的对角大小。 每个显示器的屏幕密度都会因此不同。 密度用 dpi = " dots" / 英寸 = 像素 / 英寸来测量 。

稍后能否通过代码获取密度大小, DPI(包括 x 和 Y) 通过代码获取?

是的,发自a DisplayMetrics 对象

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签