how to programmatically show and hide action bar on one activity

前端 未结 7 836
闹比i
闹比i 2020-12-10 10:12

i got this one activity wherein i need to hide actionbar on the login interface then once login it will show the action bar.i got one activity only. if i put getActionBar on

7条回答
  •  执念已碎
    2020-12-10 10:44

    Change your Theme from the manifest file for the desire Activity...

     Theme.AppCompat.NoActionBar 
        or 
     Theme.AppCompat.Light.NoActionBar
    

    Programmatically you can Invisible your Toolbar by this line of codes

    if you extend your activity by Activity class then use below line of code to show or hide the Toolbar

    getActionBar().hide();
    getActionBar().show();
    

    and if you extend your activty from AppCompact Activity then use

    For class extending Activity :

    getActionBar().hide(); getActionBar().show(); For class extending AppCompatActivity :

    getSupportActionBar().hide();
    getSupportActionBar().show();
    

提交回复
热议问题