[英]android html font size according to screen density
I need a way to say if device is LDPI or MDPI or HDPI set html font size to xeg 我需要一种方法来说明设备是LDPI还是MDPI或HDPI,将html字体大小设置为xeg
if (ldpi){
htmlString.append("<br><p align='center'><font color='Yellow' size='5'>");
}
else if (mdpi){
htmlString.append("<br><p align='center'><font color='Yellow' size='6'>");
}
else if (hdpi){
htmlString.append("<br><p align='center'><font color='Yellow' size='7'>");
}
any help would be appreciated 任何帮助,将不胜感激
For reference: http://developer.android.com/reference/android/util/DisplayMetrics.html 供参考: http : //developer.android.com/reference/android/util/DisplayMetrics.html
you can get dpi value like this; 您可以像这样获得dpi值;
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
and compare the density
property with constants; 并将density
特性与常数进行比较;
int DENSITY_DEFAULT The reference density used throughout the system.
int DENSITY_HIGH Standard quantized DPI for high-density screens.
int DENSITY_LOW Standard quantized DPI for low-density screens.
int DENSITY_MEDIUM Standard quantized DPI for medium-density screens.
int DENSITY_TV Standard quantized DPI for 720p TV screens.
int DENSITY_XHIGH
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.