CardView在紧密过渡时与现有视图重叠

问题描述

我正在尝试实现可折叠的卡片视图,开头的过渡效果很好,但闭合的过渡与下面的视图重叠,请参见GIF(由于出现嵌入错误而导致的链接):https://i.imgur.com/XOq2qxC.gif

我尝试使用android:animateLayoutChanges="true",但没有用。

布局代码

<androidx.cardview.widget.CardView
            android:id="@+id/parkAlertLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            style="@style/CardView.Light"
            android:layout_margin="8dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/weatherLayout">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="8dp">

                <!-- other text/image views - omitted -->

                <Button
                        android:id="@+id/parkArrowButton"
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:background="@drawable/ic_baseline_keyboard_arrow_down_24"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/expandableView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:visibility="gone"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/cardView"
                    android:animateLayoutChanges="true">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="12dp"
                        android:layout_marginTop="8dp"
                        android:text="Dummy text\nLine2\nLine3"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                </androidx.constraintlayout.widget.ConstraintLayout>

            </androidx.constraintlayout.widget.ConstraintLayout>

        </androidx.cardview.widget.CardView>

科特琳代码

arrowBtn.setonClickListener { view ->
            if (expandableView.visibility == View.GONE) {
                TransitionManager.beginDelayedTransition(cardView,AutoTransition())
                expandableView.visibility = View.VISIBLE
                arrowBtn.setBackgroundResource(R.drawable.ic_baseline_keyboard_arrow_up_24)
            } else {
                TransitionManager.beginDelayedTransition(cardView,AutoTransition())
                expandableView.visibility = View.GONE
                arrowBtn.setBackgroundResource(R.drawable.ic_baseline_keyboard_arrow_down_24)
            }
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...