how to set toolbar on FragmentActivity?

后端 未结 4 1654
日久生厌
日久生厌 2021-02-19 06:52

I want to set toolbar on my activity which extends FragmentActivity. I know that for use setSuppoertActionBar(toolbar) method we e

4条回答
  •  被撕碎了的回忆
    2021-02-19 07:45

    You can also create your own toolbar:

    First set up the main theme to extend Theme.AppCompat.Light.NoActionBar

    
    

    Remember to apply the theme:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.setTheme(R.style.style_1);
        // ...
    }
    

    then in your Activity's xml you can set your own custom toolbar:

    
    

    where @layout/my_toolbar may look like this:

    
    
        
    
    

提交回复
热议问题