ViewGroup inside CollapsingToolbarLayout show extra bottom padding when set fitsSystemWindows to be true

前端 未结 7 2520
有刺的猬
有刺的猬 2021-02-08 15:05

I am building an application and there is a profile fragment which shows a profile background image and some other elements. Like the screenshot below:

My quest

7条回答
  •  没有蜡笔的小新
    2021-02-08 15:44

    It looks like there is an erroneous inside your ConstraintLayout.

    This one:

    
    

    You can remove that view if you want - it looks like it is only supplying padding or acting as a divider.

    Also, you don't need to specify android:fitsSystemWindows="true" for your nested views. Apply that attribute at the top-level view only and it will work fine.

    A couple of tips that I use regularly when working with layouts are:

    1) While you are developing, I find it helpful to make your views/layouts obscene colors; like hot pink, lime green, neon purple, etc... This way, you can see obvious issues with your layout and quickly identify the offending piece. After it looks nice positionally, then you can turn the colors back to normal.

    2) Turn on "show layout bounds" by enabling on-device options through Developer Mode. This way, you can more easily see layouts' padding and margins while designing your XML layouts.

    Hope that helps!

提交回复
热议问题