1

the RecyclerView is not shown as in the picture below and i cannot find any solution. What i tried:

  • Rebuild
  • Clean project
  • Invalidate Cache

enter image description here

My build.gradle(Module:app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.user.myapplication"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
}

This is the activity_main.xml shown in the picutre

<?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:layout_height="match_parent"
    tools:context=".MainActivity"
    android:padding="8dp">

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent">


    </android.support.v7.widget.RecyclerView>

</LinearLayout>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
M.Mac
  • 699
  • 3
  • 14
  • I will add the xml code shown in the picture, but i cannot add more code since i didnt write any other code. – M.Mac Oct 02 '18 at 15:33
  • 1
    What version of Android Studio you are using? If recyclerView dependency is already added and rebuild didn't help, that might be a bug which you can use older APIs dependencies like 27.1.1 or new versions of Android Studio like canary version. – ʍѳђઽ૯ท Oct 02 '18 at 15:47
  • 1
    On display side scroll down this design you will find errors and refresh options. – Syed Hamza Hassan Oct 02 '18 at 16:00
  • 1
    @Mohsen Thanks! Your post reminded me to upgrade Android to 3.2! Now it works, sometimes it can be so easy ...:) – M.Mac Oct 02 '18 at 16:26

3 Answers3

2

Well, 28.0.0 support library-APIs dependency actually works better with Android Studio 3.2.0 and up and this is because of AndroidX migrating.

So, upgrading Android Studio will help since you already added RecyclerView dependency and there were no issues with the preview nor, no errors shown.

ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
0

The way I got rid of my gray recyclerview was pasting 'com.android.support:recyclerview-v7:28.0.0' to dependencies. Sorry in case this is what you did to begin with!

There is another way to do it which is clicking on the little download icon that appears next to recyclerview when you search for it but that always results in the grey screen for me.

Palak
  • 1
0

I had the same problem, after spending approximately 2 days to figure it out, I went forward to

•delete the activity •create a new one •then add the RecyclerView to it and it worked like charm.

ARMEL FOPA
  • 206
  • 3
  • 8
  • Consider formatting the bullets so that each of the points fall in a different line. Just add another blank line between them. – Harsh Wardhan May 13 '20 at 12:06