本文整理汇总了Java中android.util.DisplayMetrics.DENSITY_TV属性的典型用法代码示例。如果您正苦于以下问题:Java DisplayMetrics.DENSITY_TV属性的具体用法?Java DisplayMetrics.DENSITY_TV怎么用?Java DisplayMetrics.DENSITY_TV使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.util.DisplayMetrics
的用法示例。
在下文中一共展示了DisplayMetrics.DENSITY_TV属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: isTabletDevice
public boolean isTabletDevice(Context activityContext) {
boolean device_large = ((activityContext.getResources().getConfiguration().screenLayout &
Configuration.SCREENLAYOUT_SIZE_MASK) ==
Configuration.SCREENLAYOUT_SIZE_LARGE);
if (device_large) {
DisplayMetrics metrics = new DisplayMetrics();
Activity activity = (Activity) activityContext;
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT
|| metrics.densityDpi == DisplayMetrics.DENSITY_HIGH
|| metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM
|| metrics.densityDpi == DisplayMetrics.DENSITY_TV
|| metrics.densityDpi == DisplayMetrics.DENSITY_XHIGH) {
return true;
}
}
return false;
}
示例3: 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);
}
}
示例4: 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;
}
示例5: 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;
}
示例6: getWebviewAdaption
public void getWebviewAdaption(WebView webView)
{
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setUseWideViewPort(true);//关键点
//启用地理定位
webSettings.setDomStorageEnabled(true);
webSettings.setDatabaseEnabled((Boolean) SPUtils.get(context, "if_4", true));//数据库
webSettings.setGeolocationEnabled((Boolean) SPUtils.get(context, "if_2", true));//地理
webSettings.setUserAgentString("" + SPUtils.get(context, "if_7", "Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en-us) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3 XiaoMi/MiuiBrowser/8.9.4"));//UA
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webSettings.setDisplayZoomControls(false);
webSettings.setLoadsImagesAutomatically((Boolean) SPUtils.get(context, "if_5", true));//图片
webSettings.setJavaScriptEnabled((Boolean) SPUtils.get(context, "if_1", true)); // 设置支持javascript脚本
webSettings.setAllowFileAccess(true); // 允许访问文件
webSettings.setBuiltInZoomControls(true); // 设置显示缩放按钮
webSettings.setSupportZoom((Boolean) SPUtils.get(context, "if_3", false)); // 支持缩放
webSettings.setLoadWithOverviewMode(true);
DisplayMetrics metrics = new DisplayMetrics();
//getWindowManager().getDefaultDisplay().getMetrics(metrics);
int mDensity = metrics.densityDpi;
// Log.d("maomao", "densityDpi = " + mDensity);
if (mDensity == 240)
{
webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
}
else if (mDensity == 160)
{
webSettings.setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
}
else if (mDensity == 120)
{
webSettings.setDefaultZoom(WebSettings.ZoomDensity.CLOSE);
}
else if (mDensity == DisplayMetrics.DENSITY_XHIGH)
{
webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
}
else if (mDensity == DisplayMetrics.DENSITY_TV)
{
webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
}
else
{
webSettings.setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
}
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
}
示例7: isTVdpiDensity
public static Boolean isTVdpiDensity() {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
return metrics.densityDpi == DisplayMetrics.DENSITY_TV;
}