2012-03-26 12 views
0

デバイスがLDPIかMDPIかHDPIでhtmlフォントサイズをxに設定する必要があります。 例えばandroid html画面の密度に応じたフォントサイズ

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'>"); 
} 

任意のヘルプは参考のため

答えて

1

をいただければ幸いです:http://developer.android.com/reference/android/util/DisplayMetrics.html

あなたはこのようなDPI値を得ることができます。

DisplayMetrics metrics = new DisplayMetrics(); 
getWindowManager().getDefaultDisplay().getMetrics(metrics); 

であり、定数は、定数と比較されます。

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 
+0

ご協力ありがとうございます –

関連する問題