px与dp与sp之间的转换
来源:互联网 发布:2017学校网络改造方案 编辑:程序博客网 时间:2024/06/01 10:36
转载地址:http://blog.sina.com.cn/s/blog_b409c5190102w38t.html
/** * Created by haowai on 2016/12/23. * 单位转换 */public class DensityUtil { 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(Context context, float pxValue) { final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; return (int) (pxValue / fontScale + 0.5f); } public static int sp2px(Context context, float spValue) { final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; return (int) (spValue * fontScale + 0.5f); }}
0 0
- px与dp与sp之间的转换
- Android中dp、sp与px之间的相互转换
- android中px与sp,dp之间的转换
- dp sp px之间的区别与转换
- android dp与px之间转换以及px与sp之间的转换
- 代码中dp与px,px与sp的转换
- dp、px、sp之间的转换
- Android dp,px,sp之间的转换
- dp & px & sp 之间的相互转换
- 关于dp与px之间的转换
- dp与px之间的转换
- dp与px之间的转换
- android dp与px之间的转换
- dp与px之间的转换方法
- 【转】dp,px,pt,sp的区别与转换
- dp, sp, 与 px 互相转换的工具类
- dp与px,sp的安卓转换。
- 在java代码中进行px与dip(dp)、px与sp单位值的转换
- 数据结构之二叉排序树
- MaxCompute(原ODPS) MapReduce常见问题解答
- hadoop第二天
- RecyclerView中item布局的"match_parent"属性失效--LayoutInflate的深入了解
- Qt之GUI学习笔记(四)——创建对话框
- px与dp与sp之间的转换
- vue组件最佳实践
- JNI交叉编译_NDK插件
- androidStudio升级到2.3之后新建Activity布局变成了约束(ConstraintLayout)布局
- 读取网络时间
- linux 设置环境变量的方法
- 【LeetCode】500. Keyboard Row
- 很详细的事件分发机制 转载一下
- JavaScript正则表达式的分组匹配详解