gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-11-01 07:40:36 27 4
gpt4 key购买 nike

大家好,谁能建议我如何使用与设备无关的像素(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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com