android - 对话框片段未在 android 中显示视图
问题描述
我正在使用 androidx 对话框片段来显示一些内容,但它没有显示对话框视图。我的代码是
<androidx.cardview.widget.CardView
android:id="@+id/content_root"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/dp_10"
android:paddingBottom="@dimen/dp_10">
//my design
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.cardview.widget.CardView>
解决方案
这是因为 ConstraintLayout。这个问题可以通过将约束布局作为RelativeLayout的子来解决。
注意:如果您使用 LinearLayout 作为 ConstraintLayout 的父级,那么它将不起作用。
#bst