【问题标题】:Android: dps and integers [duplicate]Android:dps和整数[重复]
【发布时间】:2014-07-14 12:56:30
【问题描述】:

在我的主布局文件中,我声明了以下内容:

android:padding="10dp"

在我的代码中,我说:

int padding = getPaddingLeft();

如果我在 Eclipse 中调试代码,填充将等于整数值 20。

这是否意味着要以整数格式表示 dp,我们需要将它乘以 2?

【问题讨论】:

    标签: android


    【解决方案1】:

    没有方法返回像素值

    public int getPaddingLeft ()
    
    Added in API level 1
    Returns the left padding of this view. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
    
    Returns
    the left padding in pixels
    

    Source

    这意味着你当前使用的设备是 xhdpi 设备

    【讨论】:

      猜你喜欢
      • 2012-05-23
      • 1970-01-01
      • 1970-01-01
      • 2014-12-14
      • 1970-01-01
      • 1970-01-01
      • 2022-11-30
      • 1970-01-01
      • 2013-04-22
      相关资源
      最近更新 更多