How to access RecyclerView in androidx?

Official document : https://developer.android.com/jetpack/androidx/migrate

Step 1: Check and set the lines in gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

Step 2: Change

implementation 'com.android.support:recyclerview-v7:28.0.0'

to

implementation 'androidx.recyclerview:recyclerview:1.0.0' //Update to latest version

And finally: Change the tag

 <view class="android.support.v7.widget.RecyclerView"...>

to

<androidx.recyclerview.widget.RecyclerView
     android:id="@+id/recycler_view"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:listitem="@layout/todo_item"/>

RecyclerViewwas migrated to AndroidX as well:

  1. Updatebuild.gradle:
implementation 'androidx.recyclerview:recyclerview:1.1.0'
  1. Change layout file:
<androidx.recyclerview.widget.RecyclerView>...</androidx.recyclerview.widget.RecyclerView

If you follow the above instructions and the RecyclerView still appears as a grey box in the layout preview, try rebuilding your project.


you can use the materials design Dependencies

implementation 'com.google.android.material:material:1.2.0-alpha04'
implementation 'com.android.support:multidex:1.0.3'