android - dp转换为px 和 sp转换为px
阿神
阿神 2017-04-17 17:16:40
0
2
463
阿神
阿神

闭关修行中......

reply all(2)
PHPzhong

0.5 should ensure accuracy after rounding.
To convert to sp, you can refer to the FONT_SCALE attribute value in Settings.System to make corresponding adjustments.

迷茫
public static int sp2px(Context context, float spValue) {  
        final float scale = context.getResources().getDisplayMetrics().scaledDensity;  
        return (int) (spValue * scale + 0.5f);  
    }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!