Android 根据屏幕大小设置字体


适应不同Android手机屏幕大小

240*320

320*480

480*800

480*854

540*960

800*1200

800*1280

 
  1. public static int adjustFontSize(int screenWidth, int screenHeight){  
  2.       
  3.     if (screenWidth <= 240) {        // 240X320 屏幕   
  4.           
  5.         return 10;  
  6.   
  7.     }else if (screenWidth <= 320){   // 320X480 屏幕   
  8.   
  9.         return 14;  
  10.   
  11.     }else if (screenWidth <= 480){   // 480X800 或 480X854 屏幕   
  12.   
  13.         return 24;  
  14.   
  15.     }else if (screenWidth <= 540){   // 540X960 屏幕    
  16.   
  17.         return 26;  
  18.           
  19.     }else if(screenWidth <= 800){    // 800X1280 屏幕    
  20.   
  21.         return 30;  
  22.           
  23.     }else{                          // 大于 800X1280   
  24.   
  25.         return 30;  
  26.           
  27.     }  
  28. }  

相关内容