简体   繁体   English

Android Studio预览未正确显示RecyclerView和工具栏

[英]Android Studio Preview Not Showing RecyclerView and Toolbar Correctly

Please find the screenshots 请找到屏幕截图 屏幕截图 I searched lot for this. 我为此做了很多搜索。 My android studio is updated with 3.0.1. 我的android studio已更新为3.0.1。 Here are the dependencies in my project. 这是我项目中的依赖项。 Is the issue with studio 3.0.1? Studio 3.0.1是否存在问题?

compile 'com.android.support:appcompat-v7:23.4.+'
compile 'com.android.support:design:23.3.0'`

Here is the xml 这是XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </android.support.v7.widget.RecyclerView>
</LinearLayout>

If resolution Strategy is present in your build.gradle file then please add updated dependency as below 如果您的build.gradle文件中存在解析策略,则请按如下所示添加更新的依赖项

configurations.all {
        resolutionStrategy {
            force 'com.android.support:design:27.0.1'
            force 'com.android.support:support-v4:27.0.1'
            force 'com.android.support:appcompat-v7:27.0.1'
        }
    }

In android Studio ,Go to File->Project Structure->Dependencies Then click on green + sign and choose library dependencies. 在android Studio中,转到“文件”->“项目结构”->“依赖项”,然后单击绿色+符号并选择库依赖项。 There you can search recyclerview and include that dependency, Build your project again Hope this Helps 在那里您可以搜索recyclerview并包含该依赖项,再次构建项目希望对您有所帮助

you need to update libraries to last(nearly last) versions: 您需要将库更新为最新(接近最新)版本:

compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:support-v4:27.0.2'
compile 'com.android.support:design:27.0.2'

and change your compileSdkVersion to 27(nearly last version) 并将您的compileSdkVersion更改为27(接近最新版本)

Add these dependencies in your build.gradle file (Not in project level gradle). 将这些依赖项添加到build.gradle文件中(不在项目级别gradle中)。

implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM