美文网首页
[转] Android Studio 无法预览xml布局视图的解

[转] Android Studio 无法预览xml布局视图的解

作者: 炫子_260f | 来源:发表于2019-05-07 13:21 被阅读0次

Android Studio中无法预览xml布局。
报错提示: failed to load AppCompat ActionBar with unkNown error

image.png

解决方案

原地址:Android Studio 无法预览xml布局视图的解决办法

AndroidManifest.xml 中

    <application
        android:name=".JAcWeChatApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
    </application>`

提示的 android:theme="@style/AppTheme",在 style.xml中找到AppTheme,按照Android Studio 无法预览xml布局视图的解决办法的解决方法,将

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:navigationBarColor">@color/colorAccent</item>
    </style>

改成

    <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:navigationBarColor">@color/colorAccent</item>
    </style>

添加Base

相关文章

网友评论

      本文标题:[转] Android Studio 无法预览xml布局视图的解

      本文链接:https://www.haomeiwen.com/subject/shseoqtx.html