AndroidX recyclerview不显示空白预览

时间:2019-11-30 17:43:27

标签: android-recyclerview androidx

我已迁移到androidx,使用recyclerview时遇到问题,UI中未显示预览,任何人都可以帮助我解决这个问题。我是否需要添加任何依赖项或更改xml布局

XML

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 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:orientation="vertical"
        android:layout_height="match_parent"
        tools:context=".ScreenOne">



       <androidx.recyclerview.widget.RecyclerView
           android:id="@+id/myrv"
           android:layout_width="match_parent"
           android:layout_height="match_parent">



       </androidx.recyclerview.widget.RecyclerView>


    </LinearLayout>

GRADLE

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.arka.mr.devmani.mynotebook"
        minSdkVersion 24
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
}

enter image description here

0 个答案:

没有答案