是否有可能改变单位为Paint.setTextSize()?据我所知,这是像素,但我喜欢设置文字大小DIP多个屏幕的支持。
Is it possible to change the unit for Paint.setTextSize()? As far as I know, it's pixel but I like to set the text size in DIP for multiple screen support.
感谢
转换像这样
// 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://d.android.com/guide/practices/screens_support.html