Android的:如何在code使用DIP(密度独立像素)? [英] Android: how to use dip (density independent pixel) in code?
问题描述
我如何指定一个 INT
参数是浸?具体来说,怎么会写等价的:
机器人:layout_width =50dip
机器人:layout_height =50dip
喜欢的东西...
的LayoutParams PARAMS =新的LayoutParams(50,50)
使用这里提到的公式<一href="http://developer.android.com/guide/practices/screens_support.html#screen-independence">http://developer.android.com/guide/practices/screens_support.html#screen-independence转换默认像素密度独立的像素。或检查该<一href="http://stackoverflow.com/questions/2238883/what-is-the-correct-way-to-specify-dimensions-in-dip-from-java-$c$c">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 ?
这篇关于Android的:如何在code使用DIP(密度独立像素)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!