Adjust Full Screen

magiepooh
August 05, 2016

Adjust Full Screen

Android
StatusBar
NavigationBar

magiepooh

August 05, 2016

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

26 slides
  1. public static void hideSystemUi(Window window) { int options = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION

    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { options = options ^ View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } else { options = options | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; } window.getDecorView().setSystemUiVisibility(options); }
  2. public static void showSystemUi(Window window) { window.getDecorView() .setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE |

    View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); }
  3. Reflection <!-- Height of the status bar --> <dimen name="status_bar_height">24dp</dimen>

    <!-- Height of the bottom navigation / system bar. --> <dimen name=“navigation_bar_height">48dp</dimen> <!-- Height of the bottom navigation bar in portrait; often the same as @dimen/navigation_bar_height --> <dimen name=“navigation_bar_height_landscape">48dp</dimen> <!-- Width of the navigation bar when it is placed vertically on the screen --> <dimen name="navigation_bar_width">42dp</dimen>
  4. StatusBar Height public int getStatusBarHeight() { Point smallSize = new

    Point(); Point largeSize = new Point(); display.getCurrentSizeRange(smallSize, largeSize); // getDisplaySize() means getSize() Point displaySize = getDisplaySize(); if (displaySize.x > displaySize.y) { return displaySize.y - smallSize.y; } else { return displaySize.y - largeSize.y; } }
  5. private class ApplyInsetsListener implements android.support.v4.view.OnApplyWindowInsetsListener { @Override public WindowInsetsCompat onApplyWindowInsets(View

    v, WindowInsetsCompat insets) { if (mLastInsets != insets) { mLastInsets = insets; } return insets; } }
  6. public int getNavigationBarWidth() { return mLastInsets == null ? 0

    : mLastInsets.getSystemWindowInsetRight(); } public int getNavigationBarHeight() { return mLastInsets == null ? 0 : mLastInsets.getSystemWindowInsetBottom(); } public int getStatusBarHeight() { return mLastInsets == null ? 0 : mLastInsets.getSystemWindowInsetTop(); }

More Decks by magiepooh

Other Decks in Technology