验证后widget.Group null

问题描述

我在 samsungshuaweis 上的 crashlytics 上遇到了这些我无法重现的崩溃:

Fatal Exception: java.lang.IllegalStateException
collapsed_area must not be null

bottom_sheet 布局是:

<androidx.core.widget.nestedScrollView
    android:id="@+id/bottom_sheet_scroll"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/cl_bottom_sheet"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/dimen_24"
        android:layout_marginEnd="@dimen/dimen_24"
        android:animateLayoutChanges="true"
        android:clickable="true"
        android:focusable="true">

        <ImageView android:id="@+id/close"
        ... />

        <androidx.constraintlayout.motion.widget.MotionLayout
            android:id="@+id/group_request"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layoutDescription="@xml/gift_scene"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/close">

            <TextView
                ... />

            <com.airbnb.lottie.LottieAnimationView
                ...
                app:lottie_autoplay="true"
                app:lottie_loop="true"
                app:lottie_rawRes="@raw/gift" />

            <androidx.constraintlayout.widget.Group
                android:id="@+id/collapsed_area"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:layout_constraintBottom_toTopOf="@id/text2"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/text2"
                ... />

            <OtherViews...> 

        </androidx.constraintlayout.motion.widget.MotionLayout>

        <include
            android:id="@+id/other_layout"
            layout="@layout/other_layout" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.nestedScrollView>

在我的代码中:

override fun onViewCreated(view: View,savedInstanceState: Bundle?) {
        super.onViewCreated(view,savedInstanceState)
        bottomSheet = BottomSheetBehavior.from(bottom_sheet).apply {
            collapsed_area?.post {
                peekHeight = collapsed_area.height
            }
        ...
}

解决方法

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

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

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