android bottom sheet resize view

Viewed 90

I want to resize a view which is above bottom sheet . In this view inside I get a imageView and a min height of this view I want to to get this same like this image. I do this but it does not work good

private fun setBottomSheetCallback() {
    bottomSheetBehavior.setBottomSheetCallback(object :
        BottomSheetBehavior.BottomSheetCallback() {
        override fun onStateChanged(bottomSheet: View, newState: Int) {}
        override fun onSlide(bottomSheet: View, slideOffset: Float) {
            val h = bottomSheet.height.toFloat()
            val off = h * slideOffset


            var a =
                (getScreenHeight(this@EventActivity) - (bottomSheet.height * slideOffset).toInt()).toInt()
            Log.e("botton panel ", "${bottom_panel.height}")
            val params: ViewGroup.LayoutParams = test_view.layoutParams

            params.height = a
            test_view.layoutParams = params


            val upperState = 0.66
            val lowerState = 0.33
            if (bottomSheetBehavior.state == BottomSheetBehavior.STATE_SETTLING) {
                if (slideOffset >= upperState) {
                    bottomSheetBehavior.state =
                        BottomSheetBehavior.STATE_EXPANDED
                }
                if (slideOffset > lowerState && slideOffset < upperState) {
                    bottomSheetBehavior.state =
                        BottomSheetBehavior.STATE_HALF_EXPANDED
                }
                if (slideOffset <= lowerState) {
                    bottomSheetBehavior.state =
                        BottomSheetBehavior.STATE_COLLAPSED
                }
            }
            eventModel.bottomState = bottomSheetBehavior.state
        }

    })
}
0 Answers
Related