How to hide title bar and status bar in Android application

We can achieve full screen view in either of the two ways:
  1. Include full screen theme in AndroidManifest XML
  2. Include Window settings in onCreate method of Activity class
Include full screen theme in AndroidManifest  XML:
1<activity android:name=".YourClassName"
2android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
3</activity>
Just change YourClassName to the Activity class name ( in our application it is ‘FullScreenExampleActivity’).
Include Window settings in onCreate method of Activity class:
1package com.prgguru.android;
2 
3import android.os.Bundle;
4import android.app.Activity;
5import android.view.Window;
6import android.view.WindowManager;
7 
8public class FullScreenExampleActivity extends Activity {
9 
10    @Override
11    public void onCreate(Bundle savedInstanceState) {
12        super.onCreate(savedInstanceState);
13        //No title bar is set for the activity
14        requestWindowFeature(Window.FEATURE_NO_TITLE);
15        //Full screen is set for the Window
16        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
17                WindowManager.LayoutParams.FLAG_FULLSCREEN);
18 
19        setContentView(R.layout.main);
20    }
21 
22}

Comments

Popular posts from this blog

Styling Bottom Navigation

Lottie Animation in Android

Set Up the AWS Mobile SDK for Android