Android 显示灰色区域的Recycleview
Android 显示灰色区域的Recycleview,android,android-recyclerview,Android,Android Recyclerview,RecyclerView未如下图所示,我无法找到 任何解决方案。 我尝试的是: 重建 清洁工程 使缓存无效 My build.gradle(模块:应用程序) 这是图片中显示的activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="ht
RecyclerView
未如下图所示,我无法找到
任何解决方案。
我尝试的是:
- 重建
- 清洁工程
- 使缓存无效
<?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
迁移
因此,升级Android Studio将有所帮助,因为您已经添加了
RecyclerView
依赖项,并且预览没有问题,也没有显示错误。我摆脱灰色RecyclerView的方法是将'com.Android.support:RecyclerView-v7:28.0.0'粘贴到依赖项。对不起,如果这是你开始做的
还有另一种方法,当你搜索它时,点击出现在recyclerview旁边的下载图标,但对我来说,它总是显示在灰色屏幕上 我也有同样的问题,在花了大约2天的时间来解决它之后,我继续 •删除活动 •创建一个新的
•然后将RecyclerView添加到其中,效果非常好。我将添加图片中显示的xml代码,但我无法添加更多代码,因为我没有编写任何其他代码。您使用的是哪一版本的Android Studio?如果已经添加了recyclerView依赖项,但重建没有帮助,则可能是一个错误,您可以使用旧的API依赖项(如27.1.1)或Android Studio的新版本(如canary版本)。在显示屏上向下滚动此设计,您将发现错误和刷新选项。@Mohsen谢谢!你的帖子提醒我升级Android到3.2!现在它可以工作了,有时候很容易…:)考虑格式化项目符号,使每个点落在不同的直线上。只需在它们之间添加另一个空行。
<?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>