2014-05-25 31 views
0

在我的主要佈局文件,我已經聲明如下:安卓:DPS和整數

android:padding="10dp" 

在我的代碼,我說:

int padding = getPaddingLeft(); 

如果我在Eclipse中調試代碼,填充將等於20的整數值。

這是否意味着要以整數格式表示dp,我們需要將其倍數爲2?

回答

0

沒有那個方法返回像素值

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設備