public static String getScreenResolutions(Activity ctx) { DisplayMetrics metrics = new DisplayMetrics(); ctx.getWindowManager().getDefaultDisplay().getMetrics(metrics); String resolution = CV.RESOLUTION_ThemeMDPI; switch (metrics.densityDpi) { case DisplayMetrics.DENSITY_MEDIUM: resolution = CV.RESOLUTION_ThemeMDPI; break; case DisplayMetrics.DENSITY_HIGH: resolution = CV.RESOLUTION_ThemeHDPI; break; case DisplayMetrics.DENSITY_XHIGH: resolution = CV.RESOLUTION_ThemeXHDPI; break; case DisplayMetrics.DENSITY_XXHIGH: resolution = CV.RESOLUTION_ThemeXXHDPI; break; case DisplayMetrics.DENSITY_XXXHIGH: resolution = CV.RESOLUTION_ThemeXXXHDPI; break; case DisplayMetrics.DENSITY_560: resolution = CV.RESOLUTION_ThemeXXXHDPI; break; } return resolution;}
Set image size
public static String getScreenResolutions(Activity ctx) { DisplayMetrics metrics = new DisplayMetrics(); ctx.getWindowManager().getDefaultDisplay().getMetrics(metrics); String resolution = CV.RESOLUTION_ThemeMDPI; switch (metrics.densityDpi) { case DisplayMetrics.DENSITY_MEDIUM: resolution = CV.RESOLUTION_ThemeMDPI; break; case DisplayMetrics.DENSITY_HIGH: resolution = CV.RESOLUTION_ThemeHDPI; break; case DisplayMetrics.DENSITY_XHIGH: resolution = CV.RESOLUTION_ThemeXHDPI; break; case DisplayMetrics.DENSITY_XXHIGH: resolution = CV.RESOLUTION_ThemeXXHDPI; break; case DisplayMetrics.DENSITY_XXXHIGH: resolution = CV.RESOLUTION_ThemeXXXHDPI; break; case DisplayMetrics.DENSITY_560: resolution = CV.RESOLUTION_ThemeXXXHDPI; break; } return resolution;}
No comments:
Post a Comment