How Can we hide title bar while using action bar?

前端 未结 10 1987
闹比i
闹比i 2021-02-12 14:43

I\'m using ActionBarSherlock and I\'m trying to hide the title bar of my application but whenever I do that, I get a NullPointerException when accessing the A

相关标签:
10条回答
  • 2021-02-12 15:19

    to hide all the title bar and keep only the action bar use this code:

    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayUseLogoEnabled(false);
    

    it worked for me

    0 讨论(0)
  • 2021-02-12 15:19

    see this answer to grammatically show/hide titleBar from the ActionBarSherlock ..

    android: title bar hide

    0 讨论(0)
  • 2021-02-12 15:22

    Arci's answer is not entirely correct. If you read the Theming documentation, you can find that:

    The themes should be defined in your manifest for the entire application or on a per-activity basis. You may also define the theme in the code of each activity before calling super.onCreate(Bundle). This must be done for every activity on which you extend from one of the 'Sherlock' activity base classes and intend to use the action bar.

    In other words it would be enough for you to swap the first two lines of your original code:

    setTheme(R.style.Theme_Sherlock);
    super.onCreate(savedInstanceState);
    ...
    
    0 讨论(0)
  • 2021-02-12 15:23

    If you are using Xamarin. You can use below.

    ActionBar.Hide();
    
    0 讨论(0)
提交回复
热议问题