我需要一种方法来说明设备是LDPI还是MDPI或HDPI将html字体大小设置为x。 e.g
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'>");
}
任何帮助将不胜感激
答案 0 :(得分:1)
供参考:http://developer.android.com/reference/android/util/DisplayMetrics.html
你可以得到像这样的dpi值;
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
并将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