微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

验证后widget.Group null

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