简体   繁体   中英

hide action bar of main activity

I want to hide action bar of only one activity - main activity .

I am extending AppCompatActivity. For some reasons I don't want to change it to ActionBar

public class MainActivity extends AppCompatActivity {

I've tried u sing getActionBar() , getSupportActionBar() methods but all of them are giving NPE( NullPointerException ). That is because of using AppCompatActivity that removes the native compatibility of actionbar methods.

Is there a way to hide the action bar from only the main activity screen without extending to ActionBar ??

Use different themes in defferent activities. theme is the attribute, which you can set not only in <application> tag, but also in <activity> .

It the theme where you want to get rid of actionbar, you can use these

<item name="windowNoTitle">true</item>
 <item name="windowActionBar">false</item>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM