Example usage for android.view View SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

List of usage examples for android.view View SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

Introduction

In this page you can find the example usage for android.view View SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN.

Prototype

int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

To view the source code for android.view View SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN.

Click Source Link

Document

Flag for #setSystemUiVisibility(int) : View would like its window to be laid out as if it has requested #SYSTEM_UI_FLAG_FULLSCREEN , even if it currently hasn't.

Usage

From source file:io.plaidapp.ui.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    ButterKnife.bind(this);

    drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);

    //toolbar.inflateMenu(R.menu.main);
    setActionBar(toolbar);/*  w  ww . j a v  a  2 s . c om*/
    if (savedInstanceState == null) {
        animateToolbar();
    }

    dribbblePrefs = DribbblePrefs.get(this);
    designerNewsPrefs = DesignerNewsPrefs.get(this);
    filtersAdapter = new FilterAdapter(this, SourceManager.getSources(this),
            new FilterAdapter.FilterAuthoriser() {
                @Override
                public void requestDribbbleAuthorisation(View sharedElemeent, Source forSource) {
                    Intent login = new Intent(HomeActivity.this, DribbbleLogin.class);
                    login.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_COLOR,
                            ContextCompat.getColor(HomeActivity.this, R.color.background_dark));
                    ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(HomeActivity.this,
                            sharedElemeent, getString(R.string.transition_dribbble_login));
                    startActivityForResult(login, getAuthSourceRequestCode(forSource), options.toBundle());
                }
            });
    dataManager = new DataManager(this, filtersAdapter) {
        @Override
        public void onDataLoaded(List<? extends PlaidItem> data) {
            adapter.addAndResort(data);
            checkEmptyState();
        }
    };
    adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this));
    grid.setAdapter(adapter);
    layoutManager = new GridLayoutManager(this, columns);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return adapter.getItemColumnSpan(position);
        }
    });
    grid.setLayoutManager(layoutManager);
    grid.addOnScrollListener(gridScroll);
    grid.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) {
        @Override
        public void onLoadMore() {
            dataManager.loadAllDataSources();
        }
    });
    grid.setHasFixedSize(true);
    grid.addItemDecoration(new GridItemDividerDecoration(adapter.getDividedViewHolderClasses(), this,
            R.dimen.divider_height, R.color.divider));
    grid.setItemAnimator(new HomeGridItemAnimator());

    // drawer layout treats fitsSystemWindows specially so we have to handle insets ourselves
    drawer.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            // inset the toolbar down by the status bar height
            ViewGroup.MarginLayoutParams lpToolbar = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
            lpToolbar.topMargin += insets.getSystemWindowInsetTop();
            lpToolbar.rightMargin += insets.getSystemWindowInsetRight();
            toolbar.setLayoutParams(lpToolbar);

            // inset the grid top by statusbar+toolbar & the bottom by the navbar (don't clip)
            grid.setPadding(grid.getPaddingLeft(),
                    insets.getSystemWindowInsetTop() + ViewUtils.getActionBarSize(HomeActivity.this),
                    grid.getPaddingRight() + insets.getSystemWindowInsetRight(), // landscape
                    grid.getPaddingBottom());

            // inset the fab for the navbar
            ViewGroup.MarginLayoutParams lpFab = (ViewGroup.MarginLayoutParams) fab.getLayoutParams();
            lpFab.bottomMargin += insets.getSystemWindowInsetBottom(); // portrait
            lpFab.rightMargin += insets.getSystemWindowInsetRight(); // landscape
            fab.setLayoutParams(lpFab);

            // we place a background behind the status bar to combine with it's semi-transparent
            // color to get the desired appearance.  Set it's height to the status bar height
            View statusBarBackground = findViewById(R.id.status_bar_background);
            FrameLayout.LayoutParams lpStatus = (FrameLayout.LayoutParams) statusBarBackground
                    .getLayoutParams();
            lpStatus.height = insets.getSystemWindowInsetTop();
            statusBarBackground.setLayoutParams(lpStatus);

            // inset the filters list for the status bar / navbar
            // need to set the padding end for landscape case
            final boolean ltr = filtersList.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
            filtersList.setPaddingRelative(filtersList.getPaddingStart(),
                    filtersList.getPaddingTop() + insets.getSystemWindowInsetTop(),
                    filtersList.getPaddingEnd() + (ltr ? insets.getSystemWindowInsetRight() : 0),
                    filtersList.getPaddingBottom() + insets.getSystemWindowInsetBottom());

            // clear this listener so insets aren't re-applied
            drawer.setOnApplyWindowInsetsListener(null);

            return insets.consumeSystemWindowInsets();
        }
    });
    setupTaskDescription();

    filtersList.setAdapter(filtersAdapter);
    filtersAdapter.addFilterChangedListener(filtersChangedListener);
    filtersAdapter.addFilterChangedListener(dataManager);
    dataManager.loadAllDataSources();
    ItemTouchHelper.Callback callback = new FilterTouchHelperCallback(filtersAdapter);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(filtersList);
    checkEmptyState();
    checkConnectivity();
}

From source file:com.yahoo.mobile.client.android.yodel.ui.ImageGalleryActivity.java

@SuppressLint("NewApi")
public void hideSystemUi() {

    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                    | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

    Animator anim = AnimatorInflater.loadAnimator(this, R.animator.fade_hide);
    anim.setTarget(mCaptionPagerIndicator);
    anim.start();//from  w  w  w .  j  a  va2 s .  c  o  m

    getSupportActionBar().hide();
}

From source file:org.horaapps.leafpic.activities.PlayerActivity.java

@SuppressWarnings("ResourceAsColor")
private void initUI() {
    setSupportActionBar(toolbar);//  w  ww .  ja v a 2s  .  c  om
    toolbar.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.transparent_black));
    toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_arrow_back));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            // | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
            | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
            | View.SYSTEM_UI_FLAG_IMMERSIVE);

    toolbar.animate().translationY(-toolbar.getHeight()).setInterpolator(new AccelerateInterpolator())
            .setDuration(0).start();
    mediController_anchor.setPadding(0, 0, 0, Measure.getNavBarHeight(PlayerActivity.this));

    mediaController
            .setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.transparent_black));

    setStatusBarColor();
    setNavBarColor();
    setRecentApp(getString(org.horaapps.leafpic.R.string.app_name));
}

From source file:com.horaapps.leafpic.PlayerActivity.java

private void initUI() {

    toolbar.setBackgroundColor(//from w w  w.j av  a  2 s .  c  om
            isApplyThemeOnImgAct() ? ColorPalette.getTransparentColor(getPrimaryColor(), getTransparency())
                    : ColorPalette.getTransparentColor(getDefaultThemeToolbarColor3th(), 175));

    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_arrow_back));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                    | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                    | View.SYSTEM_UI_FLAG_IMMERSIVE);

    getWindow().getDecorView()
            .setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
                @Override
                public void onSystemUiVisibilityChange(int visibility) {
                    if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0)
                        showControls();
                    else
                        hideControls();
                }
            });
    toolbar.animate().translationY(-toolbar.getHeight()).setInterpolator(new AccelerateInterpolator())
            .setDuration(0).start();
    mediController_anchor.setPadding(0, 0, 0, Measure.getNavBarHeight(PlayerActivity.this));

    setStatusBarColor();
    setNavBarColor();
    setRecentApp(getString(R.string.app_name));
}

From source file:io.plaidapp.ui.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    ButterKnife.bind(this);

    drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);

    setActionBar(toolbar);//w  ww.  j  ava2  s .  c  om
    if (savedInstanceState == null) {
        animateToolbar();
    }
    setExitSharedElementCallback(FeedAdapter.createSharedElementReenterCallback(this));

    dribbblePrefs = DribbblePrefs.get(this);
    designerNewsPrefs = DesignerNewsPrefs.get(this);
    filtersAdapter = new FilterAdapter(this, SourceManager.getSources(this),
            new FilterAdapter.FilterAuthoriser() {
                @Override
                public void requestDribbbleAuthorisation(View sharedElement, Source forSource) {
                    Intent login = new Intent(HomeActivity.this, DribbbleLogin.class);
                    MorphTransform.addExtras(login,
                            ContextCompat.getColor(HomeActivity.this, R.color.background_dark),
                            sharedElement.getHeight() / 2);
                    ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(HomeActivity.this,
                            sharedElement, getString(R.string.transition_dribbble_login));
                    startActivityForResult(login, getAuthSourceRequestCode(forSource), options.toBundle());
                }
            });
    dataManager = new DataManager(this, filtersAdapter) {
        @Override
        public void onDataLoaded(List<? extends PlaidItem> data) {
            adapter.addAndResort(data);
            checkEmptyState();
        }
    };
    adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this));

    grid.setAdapter(adapter);
    layoutManager = new GridLayoutManager(this, columns);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return adapter.getItemColumnSpan(position);
        }
    });
    grid.setLayoutManager(layoutManager);
    grid.addOnScrollListener(toolbarElevation);
    grid.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) {
        @Override
        public void onLoadMore() {
            dataManager.loadAllDataSources();
        }
    });
    grid.setHasFixedSize(true);
    grid.addItemDecoration(new GridItemDividerDecoration(adapter.getDividedViewHolderClasses(), this,
            R.dimen.divider_height, R.color.divider));
    grid.setItemAnimator(new HomeGridItemAnimator());

    // drawer layout treats fitsSystemWindows specially so we have to handle insets ourselves
    drawer.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            // inset the toolbar down by the status bar height
            ViewGroup.MarginLayoutParams lpToolbar = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
            lpToolbar.topMargin += insets.getSystemWindowInsetTop();
            lpToolbar.leftMargin += insets.getSystemWindowInsetLeft();
            lpToolbar.rightMargin += insets.getSystemWindowInsetRight();
            toolbar.setLayoutParams(lpToolbar);

            // inset the grid top by statusbar+toolbar & the bottom by the navbar (don't clip)
            grid.setPadding(grid.getPaddingLeft() + insets.getSystemWindowInsetLeft(), // landscape
                    insets.getSystemWindowInsetTop() + ViewUtils.getActionBarSize(HomeActivity.this),
                    grid.getPaddingRight() + insets.getSystemWindowInsetRight(), // landscape
                    grid.getPaddingBottom() + insets.getSystemWindowInsetBottom());

            // inset the fab for the navbar
            ViewGroup.MarginLayoutParams lpFab = (ViewGroup.MarginLayoutParams) fab.getLayoutParams();
            lpFab.bottomMargin += insets.getSystemWindowInsetBottom(); // portrait
            lpFab.rightMargin += insets.getSystemWindowInsetRight(); // landscape
            fab.setLayoutParams(lpFab);

            View postingStub = findViewById(R.id.stub_posting_progress);
            ViewGroup.MarginLayoutParams lpPosting = (ViewGroup.MarginLayoutParams) postingStub
                    .getLayoutParams();
            lpPosting.bottomMargin += insets.getSystemWindowInsetBottom(); // portrait
            lpPosting.rightMargin += insets.getSystemWindowInsetRight(); // landscape
            postingStub.setLayoutParams(lpPosting);

            // we place a background behind the status bar to combine with it's semi-transparent
            // color to get the desired appearance.  Set it's height to the status bar height
            View statusBarBackground = findViewById(R.id.status_bar_background);
            FrameLayout.LayoutParams lpStatus = (FrameLayout.LayoutParams) statusBarBackground
                    .getLayoutParams();
            lpStatus.height = insets.getSystemWindowInsetTop();
            statusBarBackground.setLayoutParams(lpStatus);

            // inset the filters list for the status bar / navbar
            // need to set the padding end for landscape case
            final boolean ltr = filtersList.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
            filtersList.setPaddingRelative(filtersList.getPaddingStart(),
                    filtersList.getPaddingTop() + insets.getSystemWindowInsetTop(),
                    filtersList.getPaddingEnd() + (ltr ? insets.getSystemWindowInsetRight() : 0),
                    filtersList.getPaddingBottom() + insets.getSystemWindowInsetBottom());

            // clear this listener so insets aren't re-applied
            drawer.setOnApplyWindowInsetsListener(null);

            return insets.consumeSystemWindowInsets();
        }
    });
    setupTaskDescription();

    filtersList.setAdapter(filtersAdapter);
    filtersList.setItemAnimator(new FilterAdapter.FilterAnimator());
    filtersAdapter.registerFilterChangedCallback(filtersChangedCallbacks);
    dataManager.loadAllDataSources();
    ItemTouchHelper.Callback callback = new FilterTouchHelperCallback(filtersAdapter);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(filtersList);
    checkEmptyState();
}

From source file:com.example.haizhu.myvoiceassistant.ui.RobotChatActivity.java

private void setStatusBarTranslate() {
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    }/* w  w  w .  j  a v a  2  s .  c o m*/
}

From source file:org.fossasia.phimpme.leafpic.activities.PlayerActivity.java

@SuppressWarnings("ResourceAsColor")
private void initUI() {
    setSupportActionBar(toolbar);/*w w  w  .j  a v a  2s  . c o  m*/
    toolbar.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.transparent_black));
    toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_arrow_back));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            // | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
            | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
            | View.SYSTEM_UI_FLAG_IMMERSIVE);

    toolbar.animate().translationY(-toolbar.getHeight()).setInterpolator(new AccelerateInterpolator())
            .setDuration(0).start();
    mediController_anchor.setPadding(0, 0, 0, Measure.getNavBarHeight(PlayerActivity.this));

    mediaController
            .setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.transparent_black));

    setStatusBarColor();
    setNavBarColor();
    setRecentApp(getString(R.string.app_name));
}

From source file:com.yahoo.mobile.client.android.yodel.ui.ImageGalleryActivity.java

@SuppressLint("NewApi")
public void showSystemUi() {
    getWindow().getDecorView()//  w  ww .j  ava  2 s .co m
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_FULLSCREEN // keep status bar hidden
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

    Animator anim = AnimatorInflater.loadAnimator(this, R.animator.fade_show);
    anim.setTarget(mCaptionPagerIndicator);
    anim.start();

    getSupportActionBar().show();
}

From source file:info.ipeanut.googletrainingcoursedemos.advancedimmersivemode.AdvancedImmersiveModeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
    final View flagsView = inflater.inflate(R.layout.fragment_flags, container, false);
    mLowProfileCheckBox = (CheckBox) flagsView.findViewById(R.id.flag_enable_lowprof);
    mHideNavCheckbox = (CheckBox) flagsView.findViewById(R.id.flag_hide_navbar);
    mHideStatusBarCheckBox = (CheckBox) flagsView.findViewById(R.id.flag_hide_statbar);
    mImmersiveModeCheckBox = (CheckBox) flagsView.findViewById(R.id.flag_enable_immersive);
    mImmersiveModeStickyCheckBox = (CheckBox) flagsView.findViewById(R.id.flag_enable_immersive_sticky);

    Button toggleFlagsButton = (Button) flagsView.findViewById(R.id.btn_changeFlags);
    toggleFlagsButton.setOnClickListener(new View.OnClickListener() {
        @Override// ww  w.j a  va  2 s.  c  o m
        public void onClick(View view) {
            toggleUiFlags();
        }
    });

    Button presetsImmersiveModeButton = (Button) flagsView.findViewById(R.id.btn_immersive);
    presetsImmersiveModeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            // For immersive mode, the FULLSCREEN, HIDE_HAVIGATION and IMMERSIVE
            // flags should be set (you can use IMMERSIVE_STICKY instead of IMMERSIVE
            // as appropriate for your app).  The LOW_PROFILE flag should be cleared.

            // Immersive mode is primarily for situations where the user will be
            // interacting with the screen, like games or reading books.
            int uiOptions = flagsView.getSystemUiVisibility();
            uiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;
            uiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
            uiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
            uiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE;
            uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
            flagsView.setSystemUiVisibility(uiOptions);

            dumpFlagStateToLog(uiOptions);

            // The below code just updates the checkboxes to reflect which flags have been set.
            mLowProfileCheckBox.setChecked(false);
            mHideNavCheckbox.setChecked(true);
            mHideStatusBarCheckBox.setChecked(true);
            mImmersiveModeCheckBox.setChecked(true);
            mImmersiveModeStickyCheckBox.setChecked(false);
        }
    });

    Button presetsLeanbackModeButton = (Button) flagsView.findViewById(R.id.btn_leanback);
    presetsLeanbackModeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            // For leanback mode, only the HIDE_NAVE and HIDE_STATUSBAR flags
            // should be checked.  In this case IMMERSIVE should *not* be set,
            // since this mode is left as soon as the user touches the screen.
            int uiOptions = flagsView.getSystemUiVisibility();
            uiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;
            uiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
            uiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
            uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE;
            uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
            flagsView.setSystemUiVisibility(uiOptions);

            dumpFlagStateToLog(uiOptions);

            // The below code just updates the checkboxes to reflect which flags have been set.
            mLowProfileCheckBox.setChecked(false);
            mHideNavCheckbox.setChecked(true);
            mHideStatusBarCheckBox.setChecked(true);
            mImmersiveModeCheckBox.setChecked(false);
            mImmersiveModeStickyCheckBox.setChecked(false);
        }
    });

    // Setting these flags makes the content appear under the navigation
    // bars, so that showing/hiding the nav bars doesn't resize the content
    // window, which can be jarring.
    int uiOptions = flagsView.getSystemUiVisibility();
    uiOptions |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
    uiOptions |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    uiOptions |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
    flagsView.setSystemUiVisibility(uiOptions);

    return flagsView;
}

From source file:com.fastbootmobile.encore.app.PlaylistActivity.java

@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected void onCreate(Bundle savedInstance) {
    super.onCreate(savedInstance);
    setContentView(R.layout.activity_playlist);

    FragmentManager fm = getSupportFragmentManager();
    mActiveFragment = (PlaylistViewFragment) fm.findFragmentByTag(TAG_FRAGMENT);
    if (savedInstance == null) {
        mInitialIntent = getIntent().getExtras();
    } else {//from  w  w  w  .  ja  va  2s . co m
        mInitialIntent = savedInstance.getBundle(EXTRA_RESTORE_INTENT);
    }

    if (mActiveFragment == null) {
        mActiveFragment = new PlaylistViewFragment();
        fm.beginTransaction().add(R.id.playlist_container, mActiveFragment, TAG_FRAGMENT).commit();
        mActiveFragment.setArguments(mInitialIntent);
    }

    // Remove the activity title as we don't want it here
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setTitle("");
    }

    mIsEntering = true;

    if (Utils.hasLollipop()) {
        setEnterSharedElementCallback(new SharedElementCallback() {
            @Override
            public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
                View imageHeader = mActiveFragment.getHeroImageView();
                if (imageHeader != null) {
                    sharedElements.put("itemImage", imageHeader);
                }

                View albumName = mActiveFragment.findViewById(R.id.tvAlbumName);
                if (albumName != null) {
                    final int cx = albumName.getMeasuredWidth() / 4;
                    final int cy = albumName.getMeasuredHeight() / 2;
                    final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
                    final int radius = Utils.getEnclosingCircleRadius(albumName, cx, cy);

                    if (albumName.isAttachedToWindow()) {
                        if (mIsEntering) {
                            albumName.setVisibility(View.INVISIBLE);
                            Utils.animateCircleReveal(albumName, cx, cy, 0, radius, duration, 300);
                        } else {
                            albumName.setVisibility(View.VISIBLE);
                            Utils.animateCircleReveal(albumName, cx, cy, radius, 0, duration, 0);
                        }
                    }
                }
            }
        });
    }

    getWindow().getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}