Hace un tiempo he estado buscando una forma de lograr las animaciones y el diseño que presenta Samsung en sus dispositivos que corren oneUI 2.0. He intentado hacer un custom collapsingToolbarLayout pero no obtengo el mismo resultado. Cuando esta colapsado el titulo de muestra de forma brusca y el contenido se hace scroll hacia arriba y lo que quiero es que desaparezca suavemente. Que me puede estar faltando??
Codigo del Toolbar
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:id="@+id/containerHome"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@color/whiteTextColor"
app:elevation="0dp"
>
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="@color/whiteTextColor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_trip_caract"
android:layout_width="match_parent"
android:background="@null"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:menu="@menu/home_menu"
app:title=" "
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textViewAppNameCollapsing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/roboto_mono"
android:text="@string/app_name"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.3" />
<TextView
android:id="@+id/textViewTotalTripsInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toEndOf="@+id/textViewAppNameCollapsing"
app:layout_constraintStart_toStartOf="@+id/textViewAppNameCollapsing"
app:layout_constraintTop_toBottomOf="@+id/textViewAppNameCollapsing" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
>
<LinearLayout
android:id="@+id/product_linear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/layout_background"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:visibility="gone" />
<include
layout="@layout/empty_home_state"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
Ahora les muestro lo que he intentado hacer en el fragment donde esta definido ese código
Fragment_Home
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
boolean isShow = true;
int scrollRange = -1;
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (scrollRange == -1) {
scrollRange = appBarLayout.getTotalScrollRange();
}
if (scrollRange + verticalOffset < 50) {
collapsingToolbarLayout.setAnimation(AnimationUtils.makeInChildBottomAnimation(context));
collapsingToolbarLayout.setTitle("Title");
isShow = true;
} else if (isShow) {
collapsingToolbarLayout.setTitle(" ");
isShow = false;
}
}
});
Aqui no tengo idea de como podria funcionar, estuve jugando con ese ejemplo y lo que pude hacer es que me muestre el titulo no cuando esta totalmente colapsado sino cuando este a punto. No quiero eso quiero que a medida que vaya colapsandose se vaya mostrando el titulo y vaya desapareciendo el otro contenido. Espero que me puedan ayudar. Gracias!!!