Fullscreen Activity in Android?

后端 未结 30 2246
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 00:12

How do I make an activity full screen? I mean without the notification bar. Any ideas?

30条回答
  •  醉酒成梦
    2020-11-22 00:51

    You can do it programatically:

    public class ActivityName extends Activity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            // remove title
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
            setContentView(R.layout.main);
        }
    }
    

    Or you can do it via your AndroidManifest.xml file:

    
    

    Edit:

    If you are using AppCompatActivity then you need to add new theme

    
    

    and then use it.

    
    

    Thanks to https://stackoverflow.com/a/25365193/1646479

提交回复
热议问题