Android appcompat toolbar stretches when searchview gets focus

前端 未结 10 1711
猫巷女王i
猫巷女王i 2020-12-08 08:08

I\'m updating an app to use the new Toolbar instead of the regular ActionBar. In my app the user must be able to select a contact from their contac

10条回答
  •  有刺的猬
    2020-12-08 08:55

    simplest solution without changing xml and keeping translucent system bar is to add: kotlin:

    toolbar.setOnApplyWindowInsetsListener { toolbar, windowInsets ->
        toolbar.updatePadding(
            windowInsets.systemWindowInsetLeft, 
            windowInsets.systemWindowInsetTop,
            windowInsets.systemWindowInsetRight,
            0
        )
        windowInsets.consumeSystemWindowInsets()
    }
    

    please check if your fitsSystemWindows=true are placed correctly.

提交回复
热议问题