当前位置: 首页>>代码示例>>Java>>正文


Java DisplayMetrics.DENSITY_280属性代码示例

本文整理汇总了Java中android.util.DisplayMetrics.DENSITY_280属性的典型用法代码示例。如果您正苦于以下问题:Java DisplayMetrics.DENSITY_280属性的具体用法?Java DisplayMetrics.DENSITY_280怎么用?Java DisplayMetrics.DENSITY_280使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.util.DisplayMetrics的用法示例。


在下文中一共展示了DisplayMetrics.DENSITY_280属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDensity

/**
 * Maps the current display density to a string constant.
 * @param context context to use to retrieve the current display metrics
 * @return a string constant representing the current display density, or the
 *         empty string if the density is unknown
 */
static String getDensity(final Context context) {
    String densityStr = "";
    final int density = context.getResources().getDisplayMetrics().densityDpi;
    switch (density) {
        case DisplayMetrics.DENSITY_LOW:
            densityStr = "LDPI";
            break;
        case DisplayMetrics.DENSITY_MEDIUM:
            densityStr = "MDPI";
            break;
        case DisplayMetrics.DENSITY_TV:
            densityStr = "TVDPI";
            break;
        case DisplayMetrics.DENSITY_HIGH:
            densityStr = "HDPI";
            break;
        //todo uncomment in android sdk 25
        //case DisplayMetrics.DENSITY_260:
        //    densityStr = "XHDPI";
        //    break;
        case DisplayMetrics.DENSITY_280:
            densityStr = "XHDPI";
            break;
        //todo uncomment in android sdk 25
        //case DisplayMetrics.DENSITY_300:
        //    densityStr = "XHDPI";
        //    break;
        case DisplayMetrics.DENSITY_XHIGH:
            densityStr = "XHDPI";
            break;
        //todo uncomment in android sdk 25
        //case DisplayMetrics.DENSITY_340:
        //    densityStr = "XXHDPI";
        //    break;
        case DisplayMetrics.DENSITY_360:
            densityStr = "XXHDPI";
            break;
        case DisplayMetrics.DENSITY_400:
            densityStr = "XXHDPI";
            break;
        case DisplayMetrics.DENSITY_420:
            densityStr = "XXHDPI";
            break;
        case DisplayMetrics.DENSITY_XXHIGH:
            densityStr = "XXHDPI";
            break;
        case DisplayMetrics.DENSITY_560:
            densityStr = "XXXHDPI";
            break;
        case DisplayMetrics.DENSITY_XXXHIGH:
            densityStr = "XXXHDPI";
            break;
        default:
            densityStr = "other";
            break;
    }
    return densityStr;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:64,代码来源:DeviceInfo.java


注:本文中的android.util.DisplayMetrics.DENSITY_280属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。