简体   繁体   English

android html字体大小根据屏幕密度

[英]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.

相关问题 Android网格根据屏幕密度查看图像大小 - Android Grid View image size according to screen density 如果我根据特定手机设置字体大小,如何根据android中的屏幕大小更改字体大小? - How to change the font size according to the screen size in android if I set the font sizes according to a specific phone? 如何选择字体大小和Stil未来兼容,具体取决于屏幕密度/大小/ Android中图像的大小 - How to select font size and stil being future compatible depending on screen density/size/size of images in Android 屏幕尺寸和密度支持android - Screen size and density support android 根据屏幕密度缩放字体大小 - Scale font size based on screen density 如何根据Android中的设备密度和屏幕尺寸获取ImageView的最大宽度和最大高度 - How to get max-width and max-Height for ImageView According to device density and screen size in Android Android中“屏幕尺寸”和“屏幕密度”之间的区别? - Difference between “screen size” and “screen density” in Android? 根据屏幕密度或屏幕尺寸使用不同的尺寸值更好吗? - Is it better to use different dimens values according to the screen density or to the screen size? 处理Android Nougat上的密度/字体大小更改 - Handling density / font size change on Android Nougat 根据屏幕大小和密度从远程路径加载资源 - Loading resources from remote path according to screen size and density
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM