我如何指定一个 INT
参数是浸?具体来说,怎么会写等价的:
机器人:layout_width =50dip
机器人:layout_height =50dip
喜欢的东西...
的LayoutParams PARAMS =新的LayoutParams(50,50)
解决方案
使用这里提到的公式http://developer.android.com/guide/practices/screens_support.html#screen-independence转换默认像素密度独立的像素。或检查该What是从Java code指定DIP尺寸正确的方法是什么?
How do I specify that an int
parameter is in dip? Specifically, how would write the equivalent of:
android:layout_width="50dip"
android:layout_height="50dip"
Something like...:
LayoutParams params = new LayoutParams(50, 50)
解决方案
Use the formula mentioned here http://developer.android.com/guide/practices/screens_support.html#screen-independence for converting default pixel to density independent pixel. OR check this What is the correct way to specify dimensions in DIP from Java code ?