<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.MainFragment">
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
预览会是这样的:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.MainFragment">
</androidx.constraintlayout.widget.ConstraintLayout>
预览会是这样的:
我将 Android Studio 升级到 Electric Eel,现在,在 XML 中,预览经常无法像第一张图片那样正确显示。为什么会发生这种情况,我该如何解决?这个问题是在我升级了 Android Studio 后才出现的。
我也有这个问题,我将材料版本更改为 1.7.0 并且 Android Studio 布局渲染再次工作
我将 Material Design 库从 1.8.0 降级到 1.7.0,问题消失了。我认为问题出在新版本的 Material Design 上。
更新: 我下载了Android Studio Flamingo,问题解决了