dip,px,sp,px相互转换
来源:互联网 发布:淘宝直通车度量 编辑:程序博客网 时间:2024/04/30 15:05
public static int dip2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
public static int px2sp(float pxValue, float fontScale) {
return (int) (pxValue / fontScale + 0.5f);
}
public static int sp2px(float spValue, float fontScale) {
return (int) (spValue * fontScale + 0.5f);
}
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
public static int px2sp(float pxValue, float fontScale) {
return (int) (pxValue / fontScale + 0.5f);
}
public static int sp2px(float spValue, float fontScale) {
return (int) (spValue * fontScale + 0.5f);
}
- dip,px,sp,px相互转换
- dip与px相互转换
- dp,px,sp 相互转换
- dp,px,sp相互转换
- SP/DP/PX相互转换
- px,sp,dp相互转换
- dp,px,sp相互转换
- Android px,dip,sp之间的转换
- Android px、dip、sp
- px,dip,sp区别
- dip px,sp
- dip dp px sp
- Android px、dip、sp
- sp dip px
- Android--sp,px,dip
- px, dip, sp, pt
- dp dip px sp
- android dip px sp
- NPAPI插件开发
- 大学生9天徒步400余公里 垫鞋用掉3包卫生巾
- R语言在C#使用DCom中遇到的若干问题
- 龙年总结
- stagefright 架构分析(四) MediaExtractor
- dip,px,sp,px相互转换
- 如何高效利用GitHub
- java模式笔记 (一)—— 模式的简史
- java模式笔记 (二)—— 对象原则
- java模式笔记 (三)—— 创建模式
- java模式笔记 (四)—— 结构模式
- java模式笔记(五)——行为模式
- 注册邮箱激活
- PHP