首页 > 解决方案 > Android 布局预览未在 android studio 3.1.3 中加载

问题描述

这里的问题是来自android studio的预览工具不会加载我的视图,我拥有的其他视图很好。

activity_maps_view.xml

<RelativeLayout 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:id="@+id/relativeTop"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".View.MapsView">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <ImageView
                    android:id="@+id/imageView4"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    android:contentDescription="@string/signin_logoBackground"
                    android:cropToPadding="true"
                    android:scaleType="centerInside"
                    app:srcCompat="@drawable/login_logo_3x" />


            </LinearLayout>

            <android.support.design.widget.BottomNavigationView
                android:id="@+id/top_navigation_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:itemBackground="@android:color/white"
                app:itemIconTint="@drawable/nav_selector"
                app:itemTextColor="@drawable/nav_selector"
                app:menu="@menu/top_menu">

            </android.support.design.widget.BottomNavigationView>

        </LinearLayout>
    </ScrollView>

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:layout="@layout/activity_maps_view" />

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_navigation_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:itemBackground="@android:color/white"
        app:itemIconTint="@drawable/nav_selector"
        app:itemTextColor="@drawable/nav_selector"
        app:menu="@menu/bottom_menu">

    </android.support.design.widget.BottomNavigationView>
</RelativeLayout>

构建等级

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "de.bho_dive.app.android"
        minSdkVersion 21
        targetSdkVersion 27
        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(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    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.volley:volley:1.1.0'
    implementation 'com.android.support:design:27.1.1'

    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
}

错误

如您所见,预览工具不会显示任何内容,我已经尝试更改主题,更改android版本,重新启动android studio,再次导入项目,似乎没有任何效果。有任何想法吗?

标签: androidxmlandroid-studioandroid-layoutpreview

解决方案


在此处输入图像描述您是否尝试过从文件菜单中使缓存/重新启动无效

Android studio -> File -> invalidate cache/restart

推荐阅读