显示灰色区域的Recycleview [英] Recycleview displaying a grey area

查看:163
本文介绍了显示灰色区域的Recycleview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RecyclerView并未如下图所示,我找不到 任何解决方案. 我试过的:

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

  • 重建
  • 清洁项目
  • 使缓存无效

我的build.gradle(Module:app)

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'
}

这是picutre中显示的activity_main.xml

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>

推荐答案

好,28.0.0支持库API依赖项实际上在 Android Studio 3.2.0 更好起作用向上,这是由于AndroidX迁移所致.

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.

因此,升级Android Studio将有所帮助,因为您已经添加了RecyclerView依赖项,并且预览没有问题,也没有显示错误.

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

这篇关于显示灰色区域的Recycleview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆