Set System UI Visibility

Description

The following code shows how to Set System UI Visibility.

Example

Main layout xml file


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:text="Toggle Mode"
        android:onClick="onToggleClick" />
</RelativeLayout>

Main Activity Java code


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
//www.  ja  v  a  2s  .c o  m
public class MainActivity extends Activity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }    
    public void onToggleClick(View v) {
        v.setSystemUiVisibility(
                /* This flag tells Android not to shift 
                 * our layout when resizing the window to
                 * hide/show the system elements
                 */
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                /* This flag hides the system status bar.
                 */
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                /* This flag hides the on-screen controls
                 */
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                /* This flag tells the controls to stay hidden until
                 * the user brings them back explicitly with a gesture,
                 * and hide them again after a period.
                 */
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    }
}
Set System UI Visibility




















Home »
  Android »
    Android UI »




UI Basics
Action Bar
Animation
Button
Canvas
CheckBox
Clock Date Picker
Dialog
EditText
Event
Fragment
Gesture
GridView
ImageView
Layout
ListView
Map
Menu
Model
OpenGL
ProgressBar
RadioButton
Spinner
Tab
TextView
Thread
Toast
Video
View
WebView