Inflating AppBarLayout with Toolbar + TabLayout

前端 未结 7 1044
隐瞒了意图╮
隐瞒了意图╮ 2021-01-30 23:21

I currently have a DrawerLayout in my main.xml. There\'s a Toolbar wrapped in an AppBarLayout, and then a simple LinearLayout to swap out fragments.

One of the fragment

7条回答
  •  生来不讨喜
    2021-01-30 23:46

    You are able to have separate toolbar for each fragment. Its possible to set fragments toolbar as activity actionbar. Example code:

    Toolbar toolbar = (Toolbar) v.findViewById(R.id.toolbar);
     ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
    

    It should be possible to have titles, icons and other stuff as well. With it you can mimic shadow on pre lollipop devices, no matter what you have on them.

提交回复
热议问题