My setup like this:
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<RadioButton
android:id="@+id/scroll_up_radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Scroll Up" />
<RadioButton
android:id="@+id/scroll_down_radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Scroll Down" />
</RadioGroup>
<TextView
android:id="@+id/bottom_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="Botton TextView"
android:textColor="@color/black"
android:textSize="30sp"
android:gravity="center"
android:layout_gravity="bottom"
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
How to use code to make the bottom TextView
hide like this? I have tried something but didn't work:
binding.scrollUpRadioButton.setOnCheckedChangeListener { compoundButton, isChecked ->
if (isChecked) {
val params = binding.bottomTextView.layoutParams as CoordinatorLayout.LayoutParams
params.behavior = AppBarLayout.ScrollingViewBehavior()
binding.bottomTextView.requestLayout()
}
}