/** 获取屏幕高度 */ public static int getSreenHeight(Activity activity) { String height_key = "share_prefrence_screent_height"; MySharedPreference sp = new MySharedPreference(activity); if (0 != sp.getKeyInt(height_key, 0)) { return sp.getKeyInt(height_key, 0); } else { int screenHeight = activity.getWindowManager().getDefaultDisplay().getHeight(); sp.setKeyInt(height_key, screenHeight); return screenHeight; } }
/** * 获取屏幕宽度 * * @param activity * @return */ public static int getSreenWidth(Activity activity) { String width_key = "share_prefrence_screent_width"; MySharedPreference sp = new MySharedPreference(activity); if (0 != sp.getKeyInt(width_key, 0)) { return sp.getKeyInt(width_key, 0); } else { int screenWidth = activity.getWindowManager().getDefaultDisplay().getWidth(); sp.setKeyInt(width_key, screenWidth); return screenWidth; } }