How to hide the title bar for an Activity in XML with existing custom theme

前端 未结 30 2032
误落风尘
误落风尘 2020-11-22 03:28

I want to hide the titlebar for some of my activities. The problem is that I applied a style to all my activities, therefore I can\'t simply set the theme to @android:

30条回答
  •  余生分开走
    2020-11-22 03:31

    the correct answer probably is to not extend ActionbarActivity rather extend just Activity


    if you still use actionbar activity seems this is working:

    @Override
    protected void onCreate(Bundle savedInstanceState) {          
        super.onCreate(savedInstanceState);
        getSupportActionBar().hide(); //<< this
        setContentView(R.layout.activity_main);
    }
    

    seems this works too:

    styles.xml:
    
       
    

    i could do like as Scott Biggs wrote. this kind of works. except there is no theme then. i mean the settings menu's background is transparent:

    just change

    public class MainActivity extends ActionBarActivity {
    

    to Activity or FragmentActivity

    public class MainActivity extends Activity  {
    

    however i could make it look good enough using material design and not remove the actionbar: https://gist.github.com/shimondoodkin/86e56b3351b704a05e53

    1. set icon of application
    2. set colors of action bar to match design.
    3. set icon to settings menu
    4. add more icons (buttons on top)

    it is by example of material design compatibility actionbar styling.

提交回复
热议问题