Java Code Examples for android.util.DisplayMetrics#DENSITY_TV
The following examples show how to use
android.util.DisplayMetrics#DENSITY_TV .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InvariantDeviceProfile.java From Trebuchet with GNU General Public License v3.0 | 6 votes |
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; }
Example 2
Source File: BugReportLens.java From u2020 with Apache License 2.0 | 6 votes |
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); } }
Example 3
Source File: DebugView.java From u2020 with Apache License 2.0 | 6 votes |
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); } }
Example 4
Source File: BugReportLens.java From u2020-mvp with Apache License 2.0 | 6 votes |
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); } }
Example 5
Source File: DebugView.java From u2020-mvp with Apache License 2.0 | 6 votes |
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); } }
Example 6
Source File: DeviceInfo.java From Cangol-appcore with Apache License 2.0 | 6 votes |
/** * 获取设备Densitydpi 类型 * * @param context * @return */ public static String getDensityDpiStr(Context context) { switch (context.getResources().getDisplayMetrics().densityDpi) { case DisplayMetrics.DENSITY_LOW: return "LDPI"; case DisplayMetrics.DENSITY_MEDIUM: return "MDPI"; case DisplayMetrics.DENSITY_TV: return "TVDPI"; case DisplayMetrics.DENSITY_HIGH: return "HDPI"; case DisplayMetrics.DENSITY_XHIGH: return "XHDPI"; case DisplayMetrics.DENSITY_XXHIGH: return "XXHDPI"; case DisplayMetrics.DENSITY_XXXHIGH: return "XXXHDPI"; default: return ""; } }
Example 7
Source File: DeviceInfoModule.java From debugdrawer with Apache License 2.0 | 6 votes |
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 "unknown"; } }
Example 8
Source File: DeviceModule.java From DebugDrawer with Apache License 2.0 | 6 votes |
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); } }
Example 9
Source File: UIUtils.java From sms-ticket with Apache License 2.0 | 6 votes |
public static String getScreenDensityAsString(Context context) { String size = null; int density = context.getResources().getDisplayMetrics().densityDpi; if (density == DisplayMetrics.DENSITY_LOW) { size = "ldpi"; } if (density == DisplayMetrics.DENSITY_MEDIUM) { size = "mdpi"; } if (density == DisplayMetrics.DENSITY_TV) { size = "tvdpi"; } if (density == DisplayMetrics.DENSITY_HIGH) { size = "hdpi"; } if (density == DisplayMetrics.DENSITY_XHIGH) { size = "xhdpi"; } if (density == DisplayMetrics.DENSITY_XXHIGH) { size = "xxhdpi"; } return size; }
Example 10
Source File: Comman.java From XERUNG with Apache License 2.0 | 6 votes |
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; }
Example 11
Source File: Comman.java From XERUNG with Apache License 2.0 | 6 votes |
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; }
Example 12
Source File: InvariantDeviceProfile.java From LaunchEnr with GNU General Public License v3.0 | 6 votes |
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; }
Example 13
Source File: EasyDisplayMod.java From easydeviceinfo with Apache License 2.0 | 5 votes |
/** * Gets density. * * @return the density */ public final String getDensity() { String densityStr = null; 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; 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; default: //do nothing break; } return CheckValidityUtil.checkValidData(densityStr); }
Example 14
Source File: WebViewActivity.java From movienow with GNU General Public License v3.0 | 5 votes |
private void initWebSettings() { WebSettings webSettings = webViewT.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); webSettings.setDisplayZoomControls(false); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setAllowFileAccess(true); webSettings.setDefaultTextEncodingName("UTF-8"); webSettings.setLoadWithOverviewMode(true); webSettings.setUseWideViewPort(true); webSettings.setDomStorageEnabled(true); webSettings.setAppCacheMaxSize(1024 * 1024 * 8); String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath(); webSettings.setAppCachePath(appCachePath); webSettings.setAllowFileAccess(true); webSettings.setAppCacheEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int mDensity = metrics.densityDpi; 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); } }
Example 15
Source File: EmailDeviceInfoLens.java From telescope with Apache License 2.0 | 5 votes |
public static String getDensityString(DisplayMetrics displayMetrics) { switch (displayMetrics.densityDpi) { case DisplayMetrics.DENSITY_LOW: return "ldpi"; case DisplayMetrics.DENSITY_MEDIUM: return "mdpi"; case DisplayMetrics.DENSITY_TV: return "tvdpi"; case DisplayMetrics.DENSITY_HIGH: return "hdpi"; case DisplayMetrics.DENSITY_260: case DisplayMetrics.DENSITY_280: case DisplayMetrics.DENSITY_300: case DisplayMetrics.DENSITY_XHIGH: return "xhdpi"; case DisplayMetrics.DENSITY_340: case DisplayMetrics.DENSITY_360: case DisplayMetrics.DENSITY_400: case DisplayMetrics.DENSITY_420: case DisplayMetrics.DENSITY_XXHIGH: return "xxhdpi"; case DisplayMetrics.DENSITY_560: case DisplayMetrics.DENSITY_XXXHIGH: return "xxxhdpi"; default: return "unknown"; } }
Example 16
Source File: ActivityManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
static int getLauncherLargeIconSizeInner(Context context) { final Resources res = context.getResources(); final int size = res.getDimensionPixelSize(android.R.dimen.app_icon_size); final int sw = res.getConfiguration().smallestScreenWidthDp; if (sw < 600) { // Smaller than approx 7" tablets, use the regular icon size. return size; } final int density = res.getDisplayMetrics().densityDpi; switch (density) { case DisplayMetrics.DENSITY_LOW: return (size * DisplayMetrics.DENSITY_MEDIUM) / DisplayMetrics.DENSITY_LOW; case DisplayMetrics.DENSITY_MEDIUM: return (size * DisplayMetrics.DENSITY_HIGH) / DisplayMetrics.DENSITY_MEDIUM; case DisplayMetrics.DENSITY_TV: return (size * DisplayMetrics.DENSITY_XHIGH) / DisplayMetrics.DENSITY_HIGH; case DisplayMetrics.DENSITY_HIGH: return (size * DisplayMetrics.DENSITY_XHIGH) / DisplayMetrics.DENSITY_HIGH; case DisplayMetrics.DENSITY_XHIGH: return (size * DisplayMetrics.DENSITY_XXHIGH) / DisplayMetrics.DENSITY_XHIGH; case DisplayMetrics.DENSITY_XXHIGH: return (size * DisplayMetrics.DENSITY_XHIGH*2) / DisplayMetrics.DENSITY_XXHIGH; default: // The density is some abnormal value. Return some other // abnormal value that is a reasonable scaling of it. return (int)((size*1.5f) + .5f); } }
Example 17
Source File: ActivityManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Get the preferred density of icons for the launcher. This is used when * custom drawables are created (e.g., for shortcuts). * * @return density in terms of DPI */ public int getLauncherLargeIconDensity() { final Resources res = mContext.getResources(); final int density = res.getDisplayMetrics().densityDpi; final int sw = res.getConfiguration().smallestScreenWidthDp; if (sw < 600) { // Smaller than approx 7" tablets, use the regular icon size. return density; } switch (density) { case DisplayMetrics.DENSITY_LOW: return DisplayMetrics.DENSITY_MEDIUM; case DisplayMetrics.DENSITY_MEDIUM: return DisplayMetrics.DENSITY_HIGH; case DisplayMetrics.DENSITY_TV: return DisplayMetrics.DENSITY_XHIGH; case DisplayMetrics.DENSITY_HIGH: return DisplayMetrics.DENSITY_XHIGH; case DisplayMetrics.DENSITY_XHIGH: return DisplayMetrics.DENSITY_XXHIGH; case DisplayMetrics.DENSITY_XXHIGH: return DisplayMetrics.DENSITY_XHIGH * 2; default: // The density is some abnormal value. Return some other // abnormal value that is a reasonable scaling of it. return (int)((density*1.5f)+.5f); } }
Example 18
Source File: ActivityManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
static int getLauncherLargeIconSizeInner(Context context) { final Resources res = context.getResources(); final int size = res.getDimensionPixelSize(android.R.dimen.app_icon_size); final int sw = res.getConfiguration().smallestScreenWidthDp; if (sw < 600) { // Smaller than approx 7" tablets, use the regular icon size. return size; } final int density = res.getDisplayMetrics().densityDpi; switch (density) { case DisplayMetrics.DENSITY_LOW: return (size * DisplayMetrics.DENSITY_MEDIUM) / DisplayMetrics.DENSITY_LOW; case DisplayMetrics.DENSITY_MEDIUM: return (size * DisplayMetrics.DENSITY_HIGH) / DisplayMetrics.DENSITY_MEDIUM; case DisplayMetrics.DENSITY_TV: return (size * DisplayMetrics.DENSITY_XHIGH) / DisplayMetrics.DENSITY_HIGH; case DisplayMetrics.DENSITY_HIGH: return (size * DisplayMetrics.DENSITY_XHIGH) / DisplayMetrics.DENSITY_HIGH; case DisplayMetrics.DENSITY_XHIGH: return (size * DisplayMetrics.DENSITY_XXHIGH) / DisplayMetrics.DENSITY_XHIGH; case DisplayMetrics.DENSITY_XXHIGH: return (size * DisplayMetrics.DENSITY_XHIGH*2) / DisplayMetrics.DENSITY_XXHIGH; default: // The density is some abnormal value. Return some other // abnormal value that is a reasonable scaling of it. return (int)((size*1.5f) + .5f); } }
Example 19
Source File: ActivityManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
/** * Get the preferred density of icons for the launcher. This is used when * custom drawables are created (e.g., for shortcuts). * * @return density in terms of DPI */ public int getLauncherLargeIconDensity() { final Resources res = mContext.getResources(); final int density = res.getDisplayMetrics().densityDpi; final int sw = res.getConfiguration().smallestScreenWidthDp; if (sw < 600) { // Smaller than approx 7" tablets, use the regular icon size. return density; } switch (density) { case DisplayMetrics.DENSITY_LOW: return DisplayMetrics.DENSITY_MEDIUM; case DisplayMetrics.DENSITY_MEDIUM: return DisplayMetrics.DENSITY_HIGH; case DisplayMetrics.DENSITY_TV: return DisplayMetrics.DENSITY_XHIGH; case DisplayMetrics.DENSITY_HIGH: return DisplayMetrics.DENSITY_XHIGH; case DisplayMetrics.DENSITY_XHIGH: return DisplayMetrics.DENSITY_XXHIGH; case DisplayMetrics.DENSITY_XXHIGH: return DisplayMetrics.DENSITY_XHIGH * 2; default: // The density is some abnormal value. Return some other // abnormal value that is a reasonable scaling of it. return (int)((density*1.5f)+.5f); } }
Example 20
Source File: x5_WebviewSelfAdaption.java From stynico with MIT License | 4 votes |
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); }