本文整理汇总了Java中android.util.DisplayMetrics.DENSITY_XXHIGH属性的典型用法代码示例。如果您正苦于以下问题:Java DisplayMetrics.DENSITY_XXHIGH属性的具体用法?Java DisplayMetrics.DENSITY_XXHIGH怎么用?Java DisplayMetrics.DENSITY_XXHIGH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.util.DisplayMetrics
的用法示例。
在下文中一共展示了DisplayMetrics.DENSITY_XXHIGH属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLauncherIconDensity
private int getLauncherIconDensity(int requiredSize) {
// Densities typically defined by an app.
int[] densityBuckets = new int[] {
DisplayMetrics.DENSITY_LOW,
DisplayMetrics.DENSITY_MEDIUM,
DisplayMetrics.DENSITY_TV,
DisplayMetrics.DENSITY_HIGH,
DisplayMetrics.DENSITY_XHIGH,
DisplayMetrics.DENSITY_XXHIGH,
DisplayMetrics.DENSITY_XXXHIGH
};
int density = DisplayMetrics.DENSITY_XXXHIGH;
for (int i = densityBuckets.length - 1; i >= 0; i--) {
float expectedSize = ICON_SIZE_DEFINED_IN_APP_DP * densityBuckets[i]
/ DisplayMetrics.DENSITY_DEFAULT;
if (expectedSize >= requiredSize) {
density = densityBuckets[i];
}
}
return density;
}
示例2: getAvatarUrl
public String getAvatarUrl(Context context) {
if (context != null) {
final int densityDpi = context.getResources().getDisplayMetrics().densityDpi;
if ((densityDpi > DisplayMetrics.DENSITY_XXXHIGH ||
densityDpi > DisplayMetrics.DENSITY_XXHIGH ||
densityDpi > DisplayMetrics.DENSITY_XHIGH) && xhdpi_link != null) {
return xhdpi_link;
} else if (densityDpi > DisplayMetrics.DENSITY_HIGH && hdpi_link != null) {
return hdpi_link;
} else if (densityDpi > DisplayMetrics.DENSITY_MEDIUM && mdpi_link != null) {
return mdpi_link;
} else {
return ldpi_link;
}
}
return null;
}
示例3: getDpi
@TargetApi(Build.VERSION_CODES.DONUT)
public static String getDpi(WindowManager windowManager) {
if (windowManager == null) {
return "";
}
int densityDpi = getMetricsSize(windowManager);
switch (densityDpi) {
case DisplayMetrics.DENSITY_LOW:
return "ldpi";
case DisplayMetrics.DENSITY_MEDIUM:
return "mdpi";
case DisplayMetrics.DENSITY_HIGH:
return "hdpi";
case DisplayMetrics.DENSITY_XHIGH:
return "xhpdi";
case DisplayMetrics.DENSITY_XXHIGH:
default:
return "xxhdpi";
}
}
示例4: getDensityPostfix
public static String getDensityPostfix(Resources res) {
String result = null;
switch (res.getDisplayMetrics().densityDpi) {
case DisplayMetrics.DENSITY_LOW:
result = "ldpi";
break;
case DisplayMetrics.DENSITY_MEDIUM:
result = "mdpi";
break;
case DisplayMetrics.DENSITY_HIGH:
result = "hdpi";
break;
case DisplayMetrics.DENSITY_XHIGH:
result = "xhdpi";
break;
case DisplayMetrics.DENSITY_XXHIGH:
result = "xxhdpi";
break;
case DisplayMetrics.DENSITY_XXXHIGH:
result = "xxxhdpi";
break;
}
return result;
}
示例5: getDensityString
private static String getDensityString(DisplayMetrics displayMetrics) {
switch (displayMetrics.densityDpi) {
case DisplayMetrics.DENSITY_LOW:
return "ldpi";
case DisplayMetrics.DENSITY_MEDIUM:
return "mdpi";
case DisplayMetrics.DENSITY_HIGH:
return "hdpi";
case DisplayMetrics.DENSITY_XHIGH:
return "xhdpi";
case DisplayMetrics.DENSITY_XXHIGH:
return "xxhdpi";
case DisplayMetrics.DENSITY_XXXHIGH:
return "xxxhdpi";
case DisplayMetrics.DENSITY_TV:
return "tvdpi";
default:
return String.valueOf(displayMetrics.densityDpi);
}
}
示例6: getDensity
public static String getDensity(Context ctx) {
String densityStr = null;
final int density = ctx.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;
case DisplayMetrics.DENSITY_XHIGH:
densityStr = "XHDPI";
break;
case DisplayMetrics.DENSITY_400:
densityStr = "XMHDPI";
break;
case DisplayMetrics.DENSITY_XXHIGH:
densityStr = "XXHDPI";
break;
case DisplayMetrics.DENSITY_XXXHIGH:
densityStr = "XXXHDPI";
break;
}
return densityStr;
}
示例7: getSelectedItemFromDensity
/**
*
* @param density
* @return -1 if the given density does not match any of the choices we have
*/
private int getSelectedItemFromDensity(int density) {
switch (density) {
case DisplayMetrics.DENSITY_MEDIUM:
return 0;
case DisplayMetrics.DENSITY_HIGH:
return 1;
case DisplayMetrics.DENSITY_XHIGH:
return 2;
case DisplayMetrics.DENSITY_XXHIGH:
return 3;
default:
return -1;
}
}
示例8: getDensityFromSelectedItem
private int getDensityFromSelectedItem(int selection) {
switch (selection) {
case 0:
return DisplayMetrics.DENSITY_MEDIUM;
case 1:
return DisplayMetrics.DENSITY_HIGH;
case 2:
default: // default should never happen
return DisplayMetrics.DENSITY_XHIGH;
case 3:
return DisplayMetrics.DENSITY_XXHIGH;
}
}
示例9: 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;
}
示例10: isXXhdpiDensity
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static Boolean isXXhdpiDensity() {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
return metrics.densityDpi == DisplayMetrics.DENSITY_XXHIGH;
}