Android Studio的设计预览中未显示材质设计

wlp8pajw  于 2023-02-19  发布在  Android
关注(0)|答案(1)|浏览(171)

我有一个基于**androidx的简单CardView。

我想使用基于com. google. android. material. card. MaterialCardView的CardView,但在预览模式下看不到结果

我该怎么补救呢?
我的build. gradle文件:

plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
}

android {
    compileSdk 33

    defaultConfig {
        minSdk 21
        targetSdk 33

        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
        consumerProguardFiles 'consumer-rules.pro'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    buildFeatures {
        viewBinding true
    }
}

dependencies {

    implementation project(':data')
    implementation project(':domain')
    implementation project(':core')

    // Tests
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    // Dagger 2
    implementation 'com.google.dagger:dagger:2.44.2'
    kapt 'com.google.dagger:dagger-compiler:2.44.2'

    // Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'

    // UI
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'com.google.android.material:material:1.8.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'com.github.skydoves:powerspinner:1.2.4'
    implementation "androidx.coordinatorlayout:coordinatorlayout:1.2.0"

    // Fragments
    implementation 'androidx.fragment:fragment-ktx:1.5.5'

    // RecyclerView
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.cardview:cardview:1.0.0'

    // Data binding
    implementation 'com.android.databinding:viewbinding:7.4.0'

    // Paging
    implementation 'androidx.paging:paging-runtime:3.2.0-alpha03'

    // Images
    implementation 'com.squareup.picasso:picasso:2.71828'

}

我尝试使缓存无效并重新启动,但没有任何更改

a6b3iqyw

a6b3iqyw1#

您的预览似乎没有使用您的主题。
尝试在“预览”中更改主题。

相关问题