字体大小

// 根据屏幕大小自动调整字体大小
    public int autoFontSize() {
        DisplayMetrics dm = getResources().getDisplayMetrics();
        // 获取设备宽度
        int screenWidth = dm.widthPixels;
        int screenHeight = dm.heightPixels;

        screenWidth = screenWidth > screenHeight ? screenWidth : screenHeight;

        int rate = (int) (4 * (float) screenWidth / 320);
        return rate < 12 ? 12 : rate;
    }

posted @ 2013-01-11 11:15  rui90102  阅读(153)  评论(0编辑  收藏  举报