是否可以更改Paint.setTextSize()的单位?据我所知,它是像素,但我喜欢在DIP中设置文本大小以支持多屏幕.
解决方法:
像这样转换它
// The gesture threshold expressed in dip
private static final float GESTURE_THRESHOLD_DIP = 16.0f;
// Convert the dips to pixels
final float scale = getContext().getResources().getdisplayMetrics().density;
mGestureThreshold = (int) (GESTURE_THRESHOLD_DIP * scale + 0.5f);
// Use mGestureThreshold as a distance in pixels
从这里http://developer.android.com/guide/practices/screens_support.html#dips-pels