본문 바로가기

프로그래밍/안드로이드

[Android] Full Screen 만들기

android full screen - Immersive mode (몰입 모드).

추가해줘야 하는 값은 총 3개입니다.
 1. SYSTEM_UI_FLAG_HIDE_NAVIGATION
 2. SYSTEM_UI_FLAG_FULLSCREEN
 3. SYSTEM_UI_FLAG_IMMERSIVE_STICKY

public class MainActivity extends Activity {
private View decorView;
private int uiOption;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
decorView = getWindow().getDecorView();
uiOption = getWindow().getDecorView().getSystemUiVisibility();
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH )
uiOption |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN )
uiOption |= View.SYSTEM_UI_FLAG_FULLSCREEN;
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT )
uiOption |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

             //getWindow().getDecorView().setSystemUiVisibility(uiOption);
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
// super.onWindowFocusChanged(hasFocus);
if( hasFocus ) {
decorView.setSystemUiVisibility( uiOption );
}
}
}


<Androidmanifest.xml>

   <uses-sdk android:minsdkversion="13" android:targetsdkversion="19"></uses-sdk>