DensityUtil.java能处理长尾词查询的吗?

2026-04-16 14:522阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计250个文字,预计阅读时间需要1分钟。

DensityUtil.java能处理长尾词查询的吗?

javapackage com.aotom.dvr.utils;

DensityUtil.java能处理长尾词查询的吗?

import android.content.Context;import android.util.TypedValue;

/** * 工具类 - 密度转换 */public class DensityUtil { /** * 根据手机的分辨率从 dp 的单位 转成为 px(像素) */ public static int dip2px(Context context, float dpValue) { final float scale=context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); }

/** * 根据手机的分辨率从 px(像素) 的单位 转成为 dp */ public static int px2dip(Context context, float pxValue) { final float scale=context.getResources().getDisplayMetrics().density; return (int) (pxValue / scale + 0.5f); }}

DensityUtil.java

package com.aotom.dvr.utils; import android.content.Context; import android.util.TypedValue; /** * * @author ckb58 */ @SuppressWarnings({"DefaultFileTemplate", "JavaDoc", "unused"}) public class DensityUtil { private DensityUtil() { //不能实例化的的异常 throw new UnsupportedOperationException("cannot be instantiated"); } /** * dp 转 px * * @param context * @param dp * @return */ public static int dpToPx(Context context, float dp) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context .getResources().getDisplayMetrics()); } /** * sp 转 px * * @param context * @param sp * @return */ public static int spToPx(Context context, float sp) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context .getResources().getDisplayMetrics()); } /** * px 转 dp * * @param context * @param px * @return */ public static float pxToDp(Context context, float px) { return (px / context.getResources().getDisplayMetrics().density); } /** * px 转 sp * * @param context * @param px * @return */ public static float pxToSp(Context context, float px) { return (px / context.getResources().getDisplayMetrics().scaledDensity); } }

本文共计250个文字,预计阅读时间需要1分钟。

DensityUtil.java能处理长尾词查询的吗?

javapackage com.aotom.dvr.utils;

DensityUtil.java能处理长尾词查询的吗?

import android.content.Context;import android.util.TypedValue;

/** * 工具类 - 密度转换 */public class DensityUtil { /** * 根据手机的分辨率从 dp 的单位 转成为 px(像素) */ public static int dip2px(Context context, float dpValue) { final float scale=context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); }

/** * 根据手机的分辨率从 px(像素) 的单位 转成为 dp */ public static int px2dip(Context context, float pxValue) { final float scale=context.getResources().getDisplayMetrics().density; return (int) (pxValue / scale + 0.5f); }}

DensityUtil.java

package com.aotom.dvr.utils; import android.content.Context; import android.util.TypedValue; /** * * @author ckb58 */ @SuppressWarnings({"DefaultFileTemplate", "JavaDoc", "unused"}) public class DensityUtil { private DensityUtil() { //不能实例化的的异常 throw new UnsupportedOperationException("cannot be instantiated"); } /** * dp 转 px * * @param context * @param dp * @return */ public static int dpToPx(Context context, float dp) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context .getResources().getDisplayMetrics()); } /** * sp 转 px * * @param context * @param sp * @return */ public static int spToPx(Context context, float sp) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context .getResources().getDisplayMetrics()); } /** * px 转 dp * * @param context * @param px * @return */ public static float pxToDp(Context context, float px) { return (px / context.getResources().getDisplayMetrics().density); } /** * px 转 sp * * @param context * @param px * @return */ public static float pxToSp(Context context, float px) { return (px / context.getResources().getDisplayMetrics().scaledDensity); } }