RecyclerView 显示为灰色框,其名称位于中心。与已实现的音频可视化工具视图相同

RecyclerView is displayed as a grey box with it's name in the center. Same for an implemented audio Visualizer view

Here 一张图片可以更好地展示我遇到的问题...

大约一周前,我从 here 实现了一个音乐 Viusalizer。 我注意到它没有正确显示,因为它显示为灰色 window(见上图),但考虑到它不是原生插件,我没有考虑太多。

然后两天前我需要使用 RecyclerView,当我下载它时,它具有相同的 'broken' 外观(见上图)。当我看到它时,我就知道项目或 Android Studio 出了问题。

我已经在过去的几天里查看了我在互联网上能找到的所有东西,我尝试了一切,从降级 sdk 编译版本,到将 Android Studio 更新到最新版本,到从 'File' 菜单执行 "Invalidate Cache / Restart"。

, , , , , , and 是我发现并尝试过的所有东西,但到目前为止,none 帮助...

这是我的activityjava文件

package com.franchini.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

这是我的activityxml文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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">

    <com.gauravk.audiovisualizer.visualizer.BlastVisualizer
        xmlns:custom="http://schemas.android.com/apk/res-auto"
        android:id="@+id/blast"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="16dp"
        custom:avColor="@color/av_dark_blue"
        custom:avDensity="0.8"
        custom:avSpeed="normal"
        custom:avType="fill"
        custom:layout_constraintBottom_toTopOf="@+id/textView"
        custom:layout_constraintEnd_toEndOf="parent"
        custom:layout_constraintStart_toStartOf="parent"
        custom:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.v7.widget.RecyclerView
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginTop="16dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView" />

</android.support.constraint.ConstraintLayout>

这是我的样式xml文件

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

这是我的build.gradle(项目)文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的 build.gradle(应用程序)文件

apply plugin: 'com.android.application'

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

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'com.gauravk.audiovisualizer:audiovisualizer:0.9.1'

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

现在,这个问题似乎只出现在编辑器上,因为当我直接在 Android 上测试时,它就像一个魅力...

谁能帮我解决这个问题?我真的错过了什么愚蠢的东西吗?

[编辑]:我想指出的是,我对这个问题没有任何错误...

你做的没有问题。

这可能是一个有时会发生的错误。继续清理并重建您的项目。如果这没有帮助,请尝试通过 File > Invalidate Caches / Restart.

使缓存无效

我知道我发帖有点晚了... 我真的不知道我做了什么来修复它,但不知何故,当我又修整了一整天后构建项目时,编辑器中的视图修复了,它们又开始工作了,显示正确...