Translucent/Transparent status bar + CoordinatorLayout + Toolbar + Fragment

后端 未结 8 1141
难免孤独
难免孤独 2020-12-05 07:23

I have following setup:

  • I\'m using AppCompat
  • MainActivity, that holds a fragment and has a toolbar, that\'s hiding when scrolling down
8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-05 08:01

    After reading your descriptions about your question, I thought styles of Google Photos matches your requirement.

    OK, there are just some tips for your question. After my test, it works.

    • If you want to show content behind status bar, you need add true into your style when Android version level is larger than 19(namely KitKat)
    • If you want to show content behind navigation bar, you need add true into your style when Android version level is larger than 19(namely KitKat)
    • If you want to hide Toolbar smoothly when content is scrolled up and to show Toolbar smoothly when content is scrolled down, you need to add app:layout_collapseMode="parallax" into your Toolbar's attributes based on your current codes.Of course, you need coordinate Toolbar with CollapsingToolbarLayout CoordinatorLayout and AppBarLayout.

提交回复
热议问题