Translucent status bar and toolbar

后端 未结 8 1980
醉梦人生
醉梦人生 2020-12-16 12:43

I\'d like to integrate something like this:

And I\'ve done it like this, but I can\'t seem to put the imageview below the toolbar. Without the toolbar, I ca

8条回答
  •  感情败类
    2020-12-16 13:16

    Got that fixed, but toolbar is overlapping the status bar. Is there anyway to fix the padding? If I use android:fitsSystemWindows="true", status bar isn't translucent anymore.

    I've recently written a post about WindowInsets, you may check it out. I think it would resolve your issue.

    Long story short - what you have to do is to pass window insets only to Toolbar via ViewCompat.setOnApplyWindowInsetListener API. But the parent of your Toolbar should pass the window insets. In your case that won't happen, because by default LinearLayout and family layouts won't do that, you have to subclass and override onApplyWindowInsets method.

    I suggest you to read the article, where everything is described more precisely.

提交回复
热议问题