android.view.Display Java Examples
The following examples show how to use
android.view.Display.
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: Camera1Fragment.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!(getActivity() instanceof Controller)) { throw new IllegalStateException("Parent activity must implement the Controller interface."); } WindowManager windowManager = ServiceUtil.getWindowManager(getActivity()); Display display = windowManager.getDefaultDisplay(); Point displaySize = new Point(); display.getSize(displaySize); controller = (Controller) getActivity(); camera = new Camera1Controller(TextSecurePreferences.getDirectCaptureCameraId(getContext()), displaySize.x, displaySize.y, this); orderEnforcer = new OrderEnforcer<>(Stage.SURFACE_AVAILABLE, Stage.CAMERA_PROPERTIES_AVAILABLE); viewModel = ViewModelProviders.of(requireActivity(), new MediaSendViewModel.Factory(requireActivity().getApplication(), new MediaRepository())).get(MediaSendViewModel.class); }
Example #2
Source File: ChangePasswordDialog.java From PocketEOS-Android with GNU Lesser General Public License v3.0 | 6 votes |
private void setCustomDialog() { View mView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_change_password, null); sureBtn = (TextView) mView.findViewById(R.id.dialog_confirm_sure); cancleBtn = (TextView) mView.findViewById(R.id.dialog_confirm_cancle); mClearEditText = (ClearEditText) mView.findViewById(R.id.dialog_old_password); mClearEditText1 = (ClearEditText) mView.findViewById(R.id.dialog_old_two_password); mClearEditText2 = (ClearEditText) mView.findViewById(R.id.dialog_new_password); sureBtn.setOnClickListener(this); cancleBtn.setOnClickListener(this); super.setContentView(mView); WindowManager windowManager = getWindow().getWindowManager(); Display display = windowManager.getDefaultDisplay(); WindowManager.LayoutParams lp = this.getWindow().getAttributes(); lp.width = (int) (display.getWidth() * 0.78); //设置宽度 this.getWindow().setAttributes(lp); }
Example #3
Source File: WalletCodeDialog.java From PocketEOS-Android with GNU Lesser General Public License v3.0 | 6 votes |
private void setCustomDialog() { View mView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_wallet_code, null); walletCode = mView.findViewById(R.id.wallet_code); go_weixin_friend = mView.findViewById(R.id.go_weixin_friend); go_weixin_circle = mView.findViewById(R.id.go_weixin_circle); go_qq_friend = mView.findViewById(R.id.go_qq_friend); go_qzone = mView.findViewById(R.id.go_qzone); ll = mView.findViewById(R.id.ll); go_weixin_friend.setOnClickListener(this); go_weixin_circle.setOnClickListener(this); go_qq_friend.setOnClickListener(this); go_qzone.setOnClickListener(this); super.setContentView(mView); WindowManager windowManager = getWindow().getWindowManager(); Display display = windowManager.getDefaultDisplay(); WindowManager.LayoutParams lp = this.getWindow().getAttributes(); lp.width = (int) (display.getWidth() * 0.78); //设置宽度 this.getWindow().setAttributes(lp); }
Example #4
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public void onDisplayStateChange(int state) { // This method is only needed to support legacy display blanking behavior // where the display's power state is coupled to suspend or to the power HAL. // The order of operations matters here. synchronized (mLock) { if (mDisplayState != state) { mDisplayState = state; if (state == Display.STATE_OFF) { if (!mDecoupleHalInteractiveModeFromDisplayConfig) { setHalInteractiveModeLocked(false); } if (!mDecoupleHalAutoSuspendModeFromDisplayConfig) { setHalAutoSuspendModeLocked(true); } } else { if (!mDecoupleHalAutoSuspendModeFromDisplayConfig) { setHalAutoSuspendModeLocked(false); } if (!mDecoupleHalInteractiveModeFromDisplayConfig) { setHalInteractiveModeLocked(true); } } } } }
Example #5
Source File: ScreenUtil.java From QuickDevFramework with Apache License 2.0 | 6 votes |
/** * 获取屏幕高(包含虚拟键盘), 单位 px * @return screenHeight; * */ public static int getScreenHeight() { WindowManager windowManager = (WindowManager) ContextProvider.get().getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); DisplayMetrics dm = new DisplayMetrics(); Class c; try { c = Class.forName("android.view.Display"); @SuppressWarnings("unchecked") Method method = c.getMethod("getRealMetrics", DisplayMetrics.class); method.invoke(display, dm); } catch (Exception e) { e.printStackTrace(); return 0; } return dm.heightPixels; }
Example #6
Source File: YearMonthDayHourMinuteActivity.java From BigApp_Discuz_Android with Apache License 2.0 | 6 votes |
@Override protected void onStart() { WindowManager m = getWindowManager(); Display d = m.getDefaultDisplay(); // 为获取屏幕宽、高 //System.out.println("d.getHeight():" + d.getHeight()); LayoutParams p = getWindow().getAttributes(); // 获取对话框当前的参数值 p.height = (int) (d.getHeight() * 1.0); // 高度设置为屏幕的1.0 p.width = (int) (d.getWidth() * 1.0); // 宽度设置为屏幕的0.8 p.alpha = 1.0f; // 设置本身透明度 p.dimAmount = 0.0f; // 设置黑暗度 getWindow().setAttributes(p); // 设置生效 getWindow().setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); // 设置靠右对齐 super.onStart(); }
Example #7
Source File: ScreenUtils.java From NewbieGuide with Apache License 2.0 | 6 votes |
/** * 虚拟操作拦(home等)是否显示 */ public static boolean isNavigationBarShow(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); Point realSize = new Point(); display.getSize(size); display.getRealSize(realSize); return realSize.y != size.y; } else { boolean menu = ViewConfiguration.get(activity).hasPermanentMenuKey(); boolean back = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); if (menu || back) { return false; } else { return true; } } }
Example #8
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
final void init(LoadedApk packageInfo, IBinder activityToken, ActivityThread mainThread, Resources container, String basePackageName, UserHandle user) { mPackageInfo = packageInfo; mBasePackageName = basePackageName != null ? basePackageName : packageInfo.mPackageName; mResources = mPackageInfo.getResources(mainThread); if (mResources != null && container != null && container.getCompatibilityInfo().applicationScale != mResources.getCompatibilityInfo().applicationScale) { if (DEBUG) { Log.d(TAG, "loaded context has different scaling. Using container's" + " compatiblity info:" + container.getDisplayMetrics()); } mResources = mainThread.getTopLevelResources( mPackageInfo.getResDir(), Display.DEFAULT_DISPLAY, null, container.getCompatibilityInfo()); } mMainThread = mainThread; mActivityToken = activityToken; mContentResolver = new ApplicationContentResolver(this, mainThread, user); mUser = user; }
Example #9
Source File: MyActivity.java From googleads-mobile-android-examples with Apache License 2.0 | 6 votes |
private AdSize getAdSize() { // Determine the screen width (less decorations) to use for the ad width. Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics); float density = outMetrics.density; float adWidthPixels = adContainerView.getWidth(); // If the ad width isn't known, default to the full screen width. if (adWidthPixels == 0) { adWidthPixels = outMetrics.widthPixels; } int adWidth = (int) (adWidthPixels / density); return AdSize.getCurrentOrientationBannerAdSizeWithWidth(this, adWidth); }
Example #10
Source File: DensityUtil.java From HaoReader with GNU General Public License v3.0 | 6 votes |
public static Point getDisplayPoint(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); DisplayMetrics displayMetrics = new DisplayMetrics(); @SuppressWarnings("rawtypes") Class c; try { c = Class.forName("android.view.Display"); @SuppressWarnings("unchecked") Method method = c.getMethod("getRealMetrics", DisplayMetrics.class); method.invoke(display, displayMetrics); return new Point(displayMetrics.widthPixels, displayMetrics.heightPixels); } catch (Exception e) { e.printStackTrace(); } DisplayMetrics dm = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm); return new Point(dm.widthPixels, dm.heightPixels); }
Example #11
Source File: AndroidBarUtils.java From AndroidBarUtils with Apache License 2.0 | 6 votes |
/** * 是否有NavigationBar * * @param activity 上下文 * @return 是否有NavigationBar */ private static boolean hasNavBar(Activity activity) { WindowManager windowManager = activity.getWindowManager(); Display d = windowManager.getDefaultDisplay(); DisplayMetrics realDisplayMetrics = new DisplayMetrics(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { d.getRealMetrics(realDisplayMetrics); } int realHeight = realDisplayMetrics.heightPixels; int realWidth = realDisplayMetrics.widthPixels; DisplayMetrics displayMetrics = new DisplayMetrics(); d.getMetrics(displayMetrics); int displayHeight = displayMetrics.heightPixels; int displayWidth = displayMetrics.widthPixels; return (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0; }
Example #12
Source File: PPopupDialogFragment.java From PHONK with GNU General Public License v3.0 | 6 votes |
private void calculateSize() { Window window = getDialog().getWindow(); Point size = new Point(); Display display = window.getWindowManager().getDefaultDisplay(); display.getSize(size); if (mW < 0) { mWidth = WindowManager.LayoutParams.WRAP_CONTENT; } else if (mW > 1) { mWidth = WindowManager.LayoutParams.MATCH_PARENT; } else { mWidth = (int) (size.x * mW); } if (mH < 0) { mHeight = WindowManager.LayoutParams.WRAP_CONTENT; } else if (mH > 1) { mHeight = WindowManager.LayoutParams.MATCH_PARENT; } else { mHeight = (int) (size.y * mH); } }
Example #13
Source File: SubHunter.java From Learning-Java-by-Building-Android-Games-Second-Edition with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get the current device's screen resolution Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); // Initialize our size based variables based on the screen resolution numberHorizontalPixels = size.x; numberVerticalPixels = size.y; blockSize = numberHorizontalPixels / gridWidth; gridHeight = numberVerticalPixels / blockSize; Log.d("Debugging", "In onCreate"); newGame(); draw(); }
Example #14
Source File: EntityFragment.java From homeassist with Apache License 2.0 | 6 votes |
private void refreshPreferenceConfigs() { Activity activity = getActivity(); if (activity != null && !activity.isFinishing()) { Display display = getActivity().getWindowManager().getDefaultDisplay(); DisplayMetrics outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics); float density = getResources().getDisplayMetrics().density; //float dpHeight = outMetrics.heightPixels / density; float dpWidth = outMetrics.widthPixels / density; //final int spanCount = getResources().getInteger(R.integer.grid_columns); int spanCount = (int) Math.floor(dpWidth / 90.0d); final int prefCount = Integer.parseInt(mSharedPref.getString("num_columns", "0")); if (prefCount != 0) { spanCount = prefCount; } mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), spanCount)); int resId = R.anim.grid_anim; LayoutAnimationController animation = AnimationUtils.loadLayoutAnimation(getContext(), resId); mRecyclerView.setLayoutAnimation(animation); } }
Example #15
Source File: BlurUtils.java From letv with Apache License 2.0 | 6 votes |
@SuppressLint({"NewApi"}) public static void blur_3(Context context, Bitmap bkg, View view) { long startMs = System.currentTimeMillis(); Display d = ((Activity) context).getWindowManager().getDefaultDisplay(); Bitmap overlay = Bitmap.createBitmap((int) (((float) d.getWidth()) / 1.0f), (int) (((float) d.getHeight()) / 1.0f), Config.ARGB_8888); Canvas canvas = new Canvas(overlay); canvas.scale(1.0f / 1.0f, 1.0f / 1.0f); Paint paint = new Paint(); paint.setFlags(2); canvas.drawBitmap(bkg, 0.0f, 0.0f, paint); overlay = FastBlur.doBlur(overlay, (int) 100.0f, true); if (LetvUtils.getSDKVersion() >= 16) { view.setBackground(new BitmapDrawable(context.getResources(), overlay)); } else { view.setBackgroundDrawable(new BitmapDrawable(context.getResources(), overlay)); } }
Example #16
Source File: ScreenResolution.java From MyHearts with Apache License 2.0 | 6 votes |
/** * Gets resolution on old devices. * Tries the reflection to get the real resolution first. * Fall back to getDisplayMetrics if the above method failed. * */ private static Pair<Integer, Integer> getRealResolutionOnOldDevice(Context ctx) { try{ WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Method mGetRawWidth = Display.class.getMethod("getRawWidth"); Method mGetRawHeight = Display.class.getMethod("getRawHeight"); Integer realWidth = (Integer) mGetRawWidth.invoke(display); Integer realHeight = (Integer) mGetRawHeight.invoke(display); return new Pair<Integer, Integer>(realWidth, realHeight); } catch (Exception e) { DisplayMetrics disp = ctx.getResources().getDisplayMetrics(); return new Pair<Integer, Integer>(disp.widthPixels, disp.heightPixels); } }
Example #17
Source File: ScannerManager.java From attendee-checkin with Apache License 2.0 | 6 votes |
private int getDisplayInfo(Point size) { WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); if (size != null) { display.getSize(size); } int rotation = display.getRotation(); switch (rotation) { case Surface.ROTATION_0: return 0; case Surface.ROTATION_90: return 90; case Surface.ROTATION_180: return 180; case Surface.ROTATION_270: return 270; } throw new RuntimeException("Unknown screen rotation: " + rotation); }
Example #18
Source File: KcaCustomToastService.java From kcanotify_h5-master with GNU General Public License v3.0 | 6 votes |
@Override public void onConfigurationChanged(Configuration newConfig) { Display display = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point size = new Point(); display.getSize(size); screenWidth = size.x; screenHeight = size.y; Log.e("KCA", "w/h: " + String.valueOf(screenWidth) + " " + String.valueOf(screenHeight)); if (mParams != null) { mParams.x = (screenWidth - popupWidth) / 2; mParams.y = (int)((screenHeight - popupHeight) * 0.8); } super.onConfigurationChanged(newConfig); }
Example #19
Source File: FullScreenVideoViewFragment.java From CameraV with GNU General Public License v3.0 | 5 votes |
@Override public void onConfigurationChanged(Configuration newConfig) { // TODO Auto-generated method stub super.onConfigurationChanged(newConfig); Display display =getActivity().getWindowManager().getDefaultDisplay(); dims = new int[] { display.getWidth(), display.getHeight() }; initVideoPost(); }
Example #20
Source File: Permissions.java From Silence with GNU General Public License v3.0 | 5 votes |
int getWindowWidth() { WindowManager windowManager = ServiceUtil.getWindowManager(getContext()); Display display = windowManager.getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics); return metrics.widthPixels; }
Example #21
Source File: DynamicWindowUtils.java From dynamic-utils with Apache License 2.0 | 5 votes |
/** * Get the app usable screen size. * * @param context The context to get the resources and window service. * * @return The app usable screen size in point. * * @see Context#WINDOW_SERVICE * @see Point */ public static @NonNull Point getAppUsableScreenSize(@NonNull Context context) { Point size = new Point(); WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); if (windowManager != null) { Display display = windowManager.getDefaultDisplay(); size.x = display.getWidth(); size.y = display.getHeight(); } return size; }
Example #22
Source File: OAuthManagerDialogFragment.java From react-native-oauth with MIT License | 5 votes |
private LayoutParams getFullscreenLayoutParams(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // DisplayMetrics metrics = context.getResources().getDisplayMetrics(); Display display = wm.getDefaultDisplay(); int realWidth; int realHeight; if (Build.VERSION.SDK_INT >= 17){ //new pleasant way to get real metrics DisplayMetrics realMetrics = new DisplayMetrics(); display.getRealMetrics(realMetrics); realWidth = realMetrics.widthPixels; realHeight = realMetrics.heightPixels; } else if (Build.VERSION.SDK_INT >= 14) { //reflection for this weird in-between time try { Method mGetRawH = Display.class.getMethod("getRawHeight"); Method mGetRawW = Display.class.getMethod("getRawWidth"); realWidth = (Integer) mGetRawW.invoke(display); realHeight = (Integer) mGetRawH.invoke(display); } catch (Exception e) { //this may not be 100% accurate, but it's all we've got realWidth = display.getWidth(); realHeight = display.getHeight(); Log.e("Display Info", "Couldn't use reflection to get the real display metrics."); } } else { //This should be close, as lower API devices should not have window navigation bars realWidth = display.getWidth(); realHeight = display.getHeight(); } return new LayoutParams(realWidth, realHeight); }
Example #23
Source File: GraphUtils.java From your-local-weather with GNU General Public License v3.0 | 5 votes |
private static boolean isPortrait (Context cx) { Display d = ((WindowManager) cx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); if (d.getWidth() == d.getHeight()) { return false; } else { return d.getWidth() < d.getHeight(); } }
Example #24
Source File: ContextImpl.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
public Object getService(ContextImpl ctx) { Display display = ctx.mDisplay; if (display == null) { DisplayManager dm = (DisplayManager)ctx.getOuterContext().getSystemService( Context.DISPLAY_SERVICE); display = dm.getDisplay(Display.DEFAULT_DISPLAY); } return new WindowManagerImpl(display); }
Example #25
Source File: Utils.java From XERUNG with Apache License 2.0 | 5 votes |
public static int getScreenWidth(Context c) { if (screenWidth == 0) { WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); screenWidth = size.x; } return screenWidth; }
Example #26
Source File: YoukuPlayerView.java From SimplifyReader with Apache License 2.0 | 5 votes |
/** * 设置哼屏幕布局 */ public void setHorizontalLayout()// 设置横屏布局pad { playback.isFullscreen = false; Display getOrient = mActivity.getWindowManager().getDefaultDisplay(); int playWidth = (int) ((int) getOrient.getWidth() * WIDTH_RATIO); this.setLayoutParams(new LinearLayout.LayoutParams(playWidth, LinearLayout.LayoutParams.WRAP_CONTENT)); showBottonInteract(); }
Example #27
Source File: Utils.java From XERUNG with Apache License 2.0 | 5 votes |
public static int getScreenWidth(Context c) { if (screenWidth == 0) { WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); screenWidth = size.x; } return screenWidth; }
Example #28
Source File: StandOutWindow.java From LogcatViewer with GNU General Public License v3.0 | 5 votes |
private int getY(int id, int height) { Display display = mWindowManager.getDefaultDisplay(); int displayWidth = display.getWidth(); int displayHeight = display.getHeight(); int types = sWindowCache.size(); int initialY = 100 * types; int variableY = x + 200 * (100 * id) / (displayWidth - width); int rawY = initialY + variableY; return rawY % (displayHeight - height); }
Example #29
Source File: MirrorPresentationActivity.java From cwac-presentation with Apache License 2.0 | 5 votes |
private PresentationFragment buildPreso(Display display) { MirrorPresentationFragment result= MirrorPresentationFragment.newInstance(this, display); source.setMirror(result); return(result); }
Example #30
Source File: DisplayAndroidManager.java From 365browser with Apache License 2.0 | 5 votes |
DisplayAndroid getDisplayAndroid(Display display) { int sdkDisplayId = display.getDisplayId(); DisplayAndroid displayAndroid = mIdMap.get(sdkDisplayId); if (displayAndroid == null) { displayAndroid = addDisplay(display); } return displayAndroid; }