float inPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 125f, getResources().getDisplayMetrics());
1. // dip: The unit to convert from
2. // 125 : The value to apply the unit to.
3. // Current display metrics to use in the conversion -- supplies display density and scaling information.
将125dp转化为以px为单位的数值。