在约束布局中添加背景图像



我正在尝试将背景图像添加到Constraint布局中,这是我的xml的根视图。该图像显示了我是否将布局更改为线性或相对布局,但它不显示在约束布局中。原因可能是什么?

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_selected_folder_bg">
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" <--change these two lines-->
android:layout_height="match_parent"
android:background="@drawable/ic_selected_folder_bg">
</androidx.constraintlayout.widget.ConstraintLayout>

它不会显示,因为没有要包装的内容(由包装内容定义(,因为视图组中没有视图。

最新更新