Android 材料搜索栏不是';t在布局预览中显示

Android 材料搜索栏不是';t在布局预览中显示,android,android-layout,Android,Android Layout,早上好 只是想问一下为什么我的材料搜索栏的布局现在显示在这里的布局是我的代码 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent

早上好

只是想问一下为什么我的材料搜索栏的布局现在显示在这里的布局是我的代码

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ProductView">


<com.mancj.materialsearchbar.MaterialSearchBar
    style="@style/MaterialSearchBarDark"
    app:mt_speechMode="true"
    app:mt_hint="Custom hint"
    app:mt_maxSuggestionsCount="10"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:id="@+id/searchBar" />
</RelativeLayout>

以下是布局的屏幕截图:


这是因为第三方库使用了项目中可能不存在的元素。 在您的情况下,它应该是
constraintlayout

我刚才补充说

implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
对我来说,这景色是看得见的。但是,如果您没有在其他领域使用它,那么您的项目就没有必要使用它


嗨,我试过你的建议,但@Jinn还是看不见。我该怎么办?图书馆也使用卡片视图。还可以尝试实现cardview。然后重新构建项目。但我建议不要仅在查看布局时使用不需要的实现,因为这会增加应用程序大小。实现“androidx.cardview:cardview:1.0.0”