如何解决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 举报,一经查实,本站将立刻删除。