У меня есть сценарий, в котором панель инструментов / панель действий в действии имеет поведение, отличное от общего поведения панели инструментов. Он должен скрываться при прокрутке motion layout
внутри фрагмента UP и , когда прокручивается motion layout
DOWN , что является противоположностью общего поведения прокрутки.
Я пытаюсь полностью скрыть Support Action Bar
и макет панели инструментов, но без анимации и не сулит ничего хорошего, поскольку Activity содержит представление BottomNavigation, поэтому постоянное скрытие и отображение панели действий выглядит не очень хорошо.
supportActionBar?.hide()
containerToolbar.visibility = View.GONE
AppBarLayout.LayoutParams scroll-flags
явно добавляет общее поведение.
fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/collapsing_header_arc"
app:showPaths="false"
android:background="@color/white"
tools:showPaths="true">
<com.github.florent37.shapeofview.shapes.ArcView
android:id="@+id/header"
android:layout_width="0dp"
android:layout_height="200dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shape_arc_height="26dp"
android:background="@color/yellow_dark"
app:shape_arc_position="bottom">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_actionbar_gradient" />
<ScrollView
android:id="@+id/scrollview_counts_container2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/counts_container"
layout="@layout/layout_card_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</ScrollView>
</com.github.florent37.shapeofview.shapes.ArcView>
<View
android:id="@+id/guideline_anchor"
android:layout_width="wrap_content"
android:layout_height="5dp"
android:orientation="horizontal"
android:background="@color/red_dark"
app:layout_constraintTop_toBottomOf="@id/header"/>
<View
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_height="210dp"
app:layout_constraintBottom_toBottomOf="@+id/guideline_anchor"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline_anchor"
android:background="@color/btnRedAlpha" />
<androidx.core.widget.NestedScrollView
android:id="@+id/parent_parent_dashboard"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/recyclerView"
android:background="@color/transparent"
android:layout_marginTop="@dimen/marginNormal">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/parent_dashboard"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ScrollView
android:id="@+id/scrollview_counts_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/calendar_container"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintVertical_bias="0.0"
android:nestedScrollingEnabled="true"
android:visibility="gone">
<include
android:id="@+id/counts_container"
layout="@layout/layout_card_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"/>
</ScrollView>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_margin="@dimen/marginBig"
app:layout_constraintTop_toBottomOf="@id/scrollview_counts_container"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.0">
<View
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="@color/yellow_dark" />
<View
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_marginTop="@dimen/marginBig"
android:background="@color/yellow_dark"/>
<View
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_marginTop="@dimen/marginBig"
android:background="@color/yellow_dark"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<!--<androidx.appcompat.widget.AppCompatTextView-->
<!--android:id="@+id/headerText"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_marginLeft="23sp"-->
<!--android:elevation="4dp"-->
<!--android:gravity="center_vertical|left"-->
<!--android:text="I love paris"-->
<!--android:shadowColor="#3E3E3E"-->
<!--android:shadowDx="2"-->
<!--android:shadowDy="2"-->
<!--android:shadowRadius="4"-->
<!--android:textColor="@android:color/holo_blue_dark"/>-->
</androidx.constraintlayout.motion.widget.MotionLayout>
collapsing_header_arc.xml
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Transition
app:constraintSetEnd="@id/end"
app:constraintSetStart="@id/start">
<OnSwipe
app:dragDirection="dragUp"
app:touchAnchorId="@id/guideline_anchor"
app:touchAnchorSide="top" />
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@id/header"
android:layout_height="240dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<CustomAttribute
app:attributeName="arcHeightDp"
app:customFloatValue="60" />
</Constraint>
<Constraint
android:id="@id/scrollview_counts_container2">
<CustomAttribute
app:attributeName="visibility"
app:customStringValue="visible" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/header"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<CustomAttribute
app:attributeName="arcHeightDp"
app:customFloatValue="0" />
</Constraint>
<Constraint
android:id="@id/scrollview_counts_container2">
<CustomAttribute
app:attributeName="visibility"
app:customStringValue="gone" />
</Constraint>
</ConstraintSet>
</MotionScene>
Есть ли способ реализовать это?