我刚刚更新了android studio(很久以前),但是当我创建一个新的标准基本活动(使用内置模板)时,出现渲染错误,提示“异常提出在渲染过程中:android.support.design.widget.CoordinatorLayout不能转换为android.view.ViewGroup“Android Studio中的基本活动渲染错误
我很困惑,因为它只是由android studio自动生成代码。
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/com.mattdevelopment01.mateusz.homeworkhelper"
xmlns:app2="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mattdevelopment01.mateusz.homeworkhelper.Assignments">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:theme="@style/AppTheme"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_assignments" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app2:backgroundTint="@color/colorAccent"
app:srcCompat="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
尽量选择较旧的API级别 –
我可以看到您的布局的xml代码:content_assignments – Meikiem