如何从DrawerLayout中删除多余的空间

时间:2019-01-08 14:51:16

标签: android navigation navigation-drawer android-navigation-drawer slidingdrawer

  

我要删除附件屏幕中显示的突出显示的空间。我使用下面的代码来产生这种滑动效果。

[1]

private fun customizeNavigationDrawerToMakeEffect() {
    binding.drawerLayout.setScrimColor(Color.TRANSPARENT)
    val actionBarDrawerToggle =
        object : ActionBarDrawerToggle(this, binding.drawerLayout, R.string.ok, R.string.cancel) {
            private val scaleFactor = 6f

            override fun onDrawerSlide(drawerView: View, slideOffset: Float) {
                super.onDrawerSlide(drawerView, slideOffset)
                val slideX = drawerView!!.width * slideOffset
                binding.content.translationX = slideX
                binding.content.scaleX = 1 - slideOffset / scaleFactor
                binding.content.scaleY = 1 - slideOffset / scaleFactor
            }
        }

    binding.drawerLayout.addDrawerListener(actionBarDrawerToggle)
}

0 个答案:

没有答案