Example usage for android.view View SYSTEM_UI_FLAG_HIDE_NAVIGATION

List of usage examples for android.view View SYSTEM_UI_FLAG_HIDE_NAVIGATION

Introduction

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

Prototype

int SYSTEM_UI_FLAG_HIDE_NAVIGATION

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

Click Source Link

Document

Flag for #setSystemUiVisibility(int) : View has requested that the system navigation be temporarily hidden.

Usage

From source file:com.pimp.instincts.activities.GalleryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    ActivityCompat.setExitSharedElementCallback(this, exitTransitionCallback);
    super.onCreate(savedInstanceState);

    int mUIFlag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LOW_PROFILE
            | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

    getWindow().getDecorView().setSystemUiVisibility(mUIFlag);

    setContentView(R.layout.activity_gallery);
    ButterKnife.bind(this);

    setSupportActionBar(toolbar);/*from www  . ja  va 2  s.c  om*/
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    ArrayList<String> imagesList = new ArrayList<>();
    for (int i = 1; i <= 23; i++)
        imagesList.add("http://ssninstincts.org.in/img/gallery/big/" + i + ".jpg");

    galleryAdapter = new GalleryAdapter(this, imagesList);
    StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(2,
            StaggeredGridLayoutManager.VERTICAL);
    gridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);
    galleryRecyclerView.setHasFixedSize(true);
    galleryRecyclerView.setLayoutManager(gridLayoutManager);
    galleryRecyclerView.setAdapter(galleryAdapter);
}

From source file:com.example.android.immersive.ImmersiveDrawerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.immersive_drawer_activity);
    final View controlsView = findViewById(R.id.fullscreen_content_controls);
    final View contentView = findViewById(R.id.fullscreen_content);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);//  ww w  .  j  a  v a 2  s.c  o m
        configureDrawer(toolbar);
        getSupportActionBar().setTitle("");
    }
    mDecorView = getWindow().getDecorView();
    mDecorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int flags) {
            boolean visible = (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
            controlsView.animate().alpha(visible ? 1 : 0).translationY(visible ? 0 : controlsView.getHeight());
            if (getSupportActionBar() == null) {
                return;
            }
            if (visible) {
                getSupportActionBar().show();
            } else {
                getSupportActionBar().hide();
            }
        }
    });
    contentView.setClickable(true);
    final GestureDetector clickDetector = new GestureDetector(this,
            new GestureDetector.SimpleOnGestureListener() {
                @Override
                public boolean onSingleTapUp(MotionEvent e) {
                    if (!USE_FULLSCREEN) {
                        return true;
                    }
                    boolean visible = (mDecorView.getSystemUiVisibility()
                            & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
                    if (visible) {
                        hideSystemUI();
                    } else {
                        showSystemUI();
                    }
                    return true;
                }
            });
    contentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            return clickDetector.onTouchEvent(motionEvent);
        }
    });
}

From source file:org.austindroids.austindroidstestapp.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    ActionBar actionBar = getActionBar();
    actionBar.setSubtitle("Fish App");
    actionBar.setTitle("Fish App");
    actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.fish));
    // Dim navigation buttons on bottom
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    return true;//from   w  ww.  j a  va  2  s .  c  o  m
}

From source file:com.achep.acdisplay.ui.activities.AcDisplayActivity.java

@SuppressLint("NewApi")
private void populateFlags(boolean windowHasFocus) {
    final View decorView = getWindow().getDecorView();

    if (windowHasFocus) {
        int visibilityUi = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LOW_PROFILE;

        if (getConfig().isFullScreen()) {
            // Hide status bar if fullscreen mode is enabled.
            visibilityUi = visibilityUi | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_FULLSCREEN;

            if (Device.hasKitKatApi()) {
                // Hide navigation bar and flag sticky.
                visibilityUi = visibilityUi | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
            }//from  ww  w  .java  2  s .  c o m
        }

        decorView.setSystemUiVisibility(visibilityUi);
    }
}

From source file:com.near.chimerarevo.activities.TutorialActivity.java

@SuppressLint("NewApi")
@Override/*  www  . jav a 2 s .c  o  m*/
public void onWindowFocusChanged(boolean hasFocus) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (hasFocus) {
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }
    }
    super.onWindowFocusChanged(hasFocus);
}

From source file:com.bullmobi.message.ui.activities.EasyNotificationActivity.java

@SuppressLint("NewApi")
private void populateFlags(boolean windowHasFocus) {
    final View decorView = getWindow().getDecorView();

    if (windowHasFocus) {
        int visibilityUi = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LOW_PROFILE;

        if (mConfig.isFullScreen()) {
            // Hide status bar if fullscreen mode is enabled.
            visibilityUi = visibilityUi | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_FULLSCREEN;

            if (Device.hasKitKatApi()) {
                // Hide navigation bar and flag sticky.
                visibilityUi = visibilityUi | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
            }/*from   w w w.ja v a2s. com*/
        }

        decorView.setSystemUiVisibility(visibilityUi);
    }
}

From source file:com.pawnua.android.app.gpstrips.activities.TripGalleryViewPagerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_trip_gallery_viewpager);

    // https://developer.android.com/intl/ru/training/system-ui/immersive.html
    View decorView = getWindow().getDecorView();
    // Hide the status bar (Sticky Immersion)
    decorView.setSystemUiVisibility(/*w  w  w .j ava  2  s .  co  m*/
            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
                    | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

    trip = Trip.getTripByID(getIntent().getLongExtra(BaseColumns._ID, -1));

    int setCurrentItem = getIntent().getIntExtra("CurrentItem", 0);
    String currentItem = getIntent().getStringExtra(GalleryDataManager.GALLERY_CURRENT_ITEM_PATH);

    mFragmentManager = getSupportFragmentManager();
    mContext = this;

    mGalleryFolder = GalleryDataManager.createImageGallery(trip);

    // disable toolbar
    //        final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    //
    //        setSupportActionBar(toolbar);
    //
    //        ActionBar actionBar = getSupportActionBar();
    //        actionBar.setDisplayHomeAsUpEnabled(true);
    //        actionBar.setTitle(getTripTitle(trip));

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        GalleryViewPagerAdapter galleryViewPagerAdapter = new GalleryViewPagerAdapter(mFragmentManager,
                GalleryDataManager.getFileImages(mGalleryFolder));
        viewPager.setAdapter(galleryViewPagerAdapter);
        if (setCurrentItem != 0)
            viewPager.setCurrentItem(setCurrentItem);
        if (currentItem != "")
            viewPager.setCurrentItem(galleryViewPagerAdapter.getItemPosition(currentItem));

    }

}

From source file:cn.androidy.materialdesignsample.immersivemode.ImmersiveModeFragment.java

/**
 * Detects and toggles immersive mode (also known as "hidey bar" mode).
 *//*from www  . j a  v  a 2  s  .  c o  m*/
public void toggleHideyBar() {

    // BEGIN_INCLUDE (get_current_ui_flags)
    // The UI options currently enabled are represented by a bitfield.
    // getSystemUiVisibility() gives us that bitfield.
    int uiOptions = getActivity().getWindow().getDecorView().getSystemUiVisibility();
    int newUiOptions = uiOptions;
    // END_INCLUDE (get_current_ui_flags)
    // BEGIN_INCLUDE (toggle_ui_flags)
    boolean isImmersiveModeEnabled = ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
    if (isImmersiveModeEnabled) {
        Log.i(TAG, "Turning immersive mode mode off. ");
    } else {
        Log.i(TAG, "Turning immersive mode mode on.");
    }

    // Navigation bar hiding:  Backwards compatible to ICS.
    if (Build.VERSION.SDK_INT >= 14) {
        newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }

    // Status bar hiding: Backwards compatible to Jellybean
    if (Build.VERSION.SDK_INT >= 16) {
        newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
    }

    // Immersive mode: Backward compatible to KitKat.
    // Note that this flag doesn't do anything by itself, it only augments the behavior
    // of HIDE_NAVIGATION and FLAG_FULLSCREEN.  For the purposes of this sample
    // all three flags are being toggled together.
    // Note that there are two immersive mode UI flags, one of which is referred to as "sticky".
    // Sticky immersive mode differs in that it makes the navigation and status bars
    // semi-transparent, and the UI flag does not get cleared when the user interacts with
    // the screen.
    if (Build.VERSION.SDK_INT >= 18) {
        newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }

    getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
    //END_INCLUDE (set_ui_flags)
}

From source file:com.webmons.disono.toolbar.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    ActionBar actionBar = getSupportActionBar();
    FragmentManager fragmentManager = getSupportFragmentManager();

    switch (item.getItemId()) {
    case R.id.action_refresh:
        Toast.makeText(MainActivity.this, "Refresh", Toast.LENGTH_SHORT).show();
        HomeFragment homeFragment = new HomeFragment();

        // add the fragment
        fragmentManager.beginTransaction().replace(R.id.activityParentView, homeFragment).addToBackStack(null) // add to history stack
                .commit();//from  w ww . ja v  a 2s  .  c o  m

        // ensure all transactions is finished
        fragmentManager.executePendingTransactions();

        break;
    case R.id.action_settings:
        Toast.makeText(MainActivity.this, "Settings", Toast.LENGTH_SHORT).show();

        ContextualToolbar contextualToolbar = new ContextualToolbar();

        // add the fragment
        fragmentManager.beginTransaction().replace(R.id.activityParentView, contextualToolbar)
                .addToBackStack(null) // add to history stack
                .commit();

        // ensure all transactions is finished
        fragmentManager.executePendingTransactions();

        break;
    case R.id.show_toolbar:
        // show actionbar
        if (actionBar != null) {
            actionBar.show();
        }
        break;
    case R.id.hide_toolbar:
        // hide actionbar
        if (actionBar != null) {
            actionBar.hide();

            // dimming the navigation buttons
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
        }
        break;
    case R.id.change_title_toolbar:
        // change title
        if (actionBar != null) {
            actionBar.setSubtitle("");
            actionBar.setTitle("Updated Title");
        }
        break;
    case R.id.immersive_toolbar:
        hideSystemUI();
        break;
    default:
        break;
    }

    return true;
}

From source file:uk.co.fuuzetsu.turnofwar.GameActivity.java

@SuppressLint("NewApi")
@Override//from   ww w.j ava2  s  .  c  o m
protected final void onCreate(final Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    // remove the title bar
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    int currentApiVersion = android.os.Build.VERSION.SDK_INT;
    final int flags = 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
            | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

    // This work only for android 4.4+
    if (currentApiVersion >= 19) {

        getWindow().getDecorView().setSystemUiVisibility(flags);
        // Code below is for case when you press Volume up or Volume down.
        // Without this after pressing valume buttons navigation bar will
        // show up and don't hide
        final View decorView = getWindow().getDecorView();
        decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {

            @Override
            public void onSystemUiVisibilityChange(int visibility) {
                if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                    decorView.setSystemUiVisibility(flags);
                }
            }
        });
    } else {
        // remove the status bar
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        Log.d(TAG, "in onCreate");
        // setContentView(R.layout.loading_screen);
        Log.d(TAG, "on inCreate");
    }
}