如何设置单位Paint.setTextSize() [英] How to set unit for Paint.setTextSize()

查看:1869
本文介绍了如何设置单位Paint.setTextSize()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能改变单位为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

从这里<一个href="http://d.android.com/guide/practices/screens_support.html">http://d.android.com/guide/practices/screens_support.html

这篇关于如何设置单位Paint.setTextSize()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆