首页 > 解决方案 > android studio 将控件显示为文本

问题描述

即使我在 build.gradle 文件中添加了来自 'com.android.support:support-v4:28.0.0' 的控件,Android Studio 也没有正确显示

我已经尝试将我的 styles.xml 中的 AppTheme 设置为“Base.Theme.AppCompat.Light.DarkActionBar”并尝试了多次重建

<android.support.v4.widget.DrawerLayout 
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"
android:orientation="vertical"/>

这里的 'android.support.v4.widget.DrawerLayout' 在预览中显示为 android.support.v4.widget.DrawerLayout

[这是预览中显示的内容][1]

一只忙碌的猫

这是我的gradle.build文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.alto.alizer.altovpn"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            minifyEnabled true
            shrinkResources false
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design: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'
}

标签: javaandroidxml

解决方案


推荐阅读