java - 如何在android中使用dip和sip

标签 java android eclipse

大家好,大家好, 任何人都可以建议我如何使用设备独立像素(dip),sip 并使用示例代码将 px 转换为 dip..

最佳答案

看看这个。

Density-independent pixel (dip)

A virtual pixel unit that applications can use in defining their UI, to express layout dimensions or position in a density-independent way.
The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, the baseline density assumed by the platform (as described later in this document). At run time, the platform transparently handles any scaling of the dip units needed, based on the actual density of the screen in use. The conversion of dip units to screen pixels is simple: pixels = dips * (density / 160). For example, on 240 dpi screen, 1 dip would equal 1.5 physical pixels. Using dip units to define your application's UI is highly recommended, as a way of ensuring proper display of your UI on different screens.

关于java - 如何在android中使用dip和sip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4232352/

相关文章:

java - 将数组中字符串中的字符复制到新数组中

java - 捕获 oracle 序列并将其设置到 JPA 中的另一个字段

java - OpenGL es 2.0 Android 纹理

android - React-Native 中带有实心阴影的文本

java - SelectOneMenu 没有任何可供选择的值

android - 构建从 Eclipse git 导入的项目作为 Android 项目

java - 有没有办法只通过国家名称获得时区?

android - 能够根据版本动态解析模块依赖关系

android - 从 APK 安装应用程序时出现 java.lang.ClassNotFoundException

java - 在 Intent 之间传递类 ArrayList