1. NotificationBar Hide
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN ) { getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); }
2. NotificationBar Show
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN ) { getWindow().setFlags( 0, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { View decorView = getWindow().getDecorView(); int uiOptions = decorView.getSystemUiVisibility(); uiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); }
MainActivity.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | package com.example.actionbar; import android.annotation.SuppressLint; import android.os.Build; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.view.WindowManager; @SuppressLint("NewApi") public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getActionBar().setTitle("ActionBar Title"); getActionBar().setSubtitle("ActionBar Subtitle"); } public void onClicNotificationBarHide(View v) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN ) { getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); } } public void onClicNotificationBarShow(View v) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN ) { getWindow().setFlags( 0, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { View decorView = getWindow().getDecorView(); int uiOptions = decorView.getSystemUiVisibility(); uiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); } } } |
activity_main.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Hide NotificationBar" android:onClick="onClicNotificationBarHide" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Show NotificationBar" android:onClick="onClicNotificationBarShow" /> </LinearLayout> |
ScreenShot:
1. [Hide NotificationBar] Pressed
2. [Show NotificationBar] Pressed
댓글 없음:
댓글 쓰기