Android NestedScrollView item height animation change cause item disappear
my goal is to implement this
I’m trying to apply the same logic here
it works well if the layout simple like that
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/layout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> <ImageView android:id="@+id/image" android:layout_width="match_parent" android:layout_height="350dp" android:background="@android:color/holo_red_dark" android:src="@android:drawable/btn_star_big_on" tools:ignore="ContentDescription" /> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center|bottom" android:layout_marginBottom="32dp" android:text="click" android:textSize="18sp" /> </FrameLayout>
but, then I try to make code more complex like that the logic does not work as expected
<?xml version="1.0" encoding="utf-8"?> <layout 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"> <RelativeLayout android:id="@+id/productLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorWhite" android:layoutDirection="locale" android:orientation="vertical" android:visibility="gone" tools:context=".Activities.ProductDetailsActivity"> <androidx.core.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/addToBag"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/sliderLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <com.smarteist.autoimageslider.SliderView android:id="@+id/imageSlider" android:layout_width="match_parent" android:layout_height="450dp" app:sliderAnimationDuration="600" app:sliderAutoCycleDirection="back_and_forth" app:sliderAutoCycleEnabled="true" app:sliderCircularHandlerEnabled="true" app:sliderIndicatorAnimationDuration="1000" app:sliderIndicatorGravity="center_horizontal|bottom" app:sliderIndicatorMargin="20.5dp" app:sliderIndicatorOrientation="horizontal" app:sliderIndicatorPadding="3dp" app:sliderIndicatorRadius="2dp" app:sliderIndicatorSelectedColor="#6E6C6C" app:sliderIndicatorUnselectedColor="@color/grayColorE" app:sliderScrollTimeInSec="8" app:sliderStartAutoCycle="true" /> </LinearLayout> </RelativeLayout> </androidx.core.widget.NestedScrollView> <TextView android:id="@+id/addToBag" android:layout_width="match_parent" android:layout_height="64dp" android:layout_alignParentBottom="true" android:layout_marginTop="28dp" android:background="@color/colorPrimary" android:fontFamily="@font/futura_heavy" android:gravity="center" android:padding="@dimen/_8sdp" android:text="@string/add_to_bag" android:textAllCaps="true" android:textColor="@color/colorWhite" android:textSize="@dimen/_11sdp" /> </RelativeLayout> </layout>
and code for slider item click is:
viewHolder.itemView.setOnClickListener(v -> { TransitionManager.beginDelayedTransition(sliderView, new TransitionSet() .addTransition(new ChangeBounds()) .addTransition(new ChangeImageTransform())); ViewGroup.LayoutParams params = imageSlider.getLayoutParams(); params.height = isApplied ? MATCH_PARENT : UiUtils.dpToPx(450); imageSlider.setScaleType(isApplied ? ImageView.ScaleType.CENTER_CROP : ImageView.ScaleType.FIT_XY); sliderView.setLayoutParams(params); imageSlider.setLayoutParams(params); isApplied = !isApplied; });
the result is the slider itself is hidden, so can anyone assist me, please? if there is another way to achieve the video, please mention