Android Studio 无法预览xml布局视图的解决办法

解决办法:

在AndroidManifest.xml文件中找到 全局样式文件 Theme,如图:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.zxn.popup">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

进入到这个文件,在前面增加 "Base".,修改后如图:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Base.Theme.AppCompat.Light">
    </style>

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

</resources>

最终结果:


image.png
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 177,111评论 25 709
  • 1.想象自己不努力会出现什么后果,给自己一个坚持下去的理由 2.要有坚持下去的决心 3.制定目标计划并严格执行
    简书米阅读 1,153评论 0 0
  • 晚上去看了学校举行的歌手大赛,激动万分!那些在像在电影里面看到的高富帅,白富美(富不富我就不知道了)都现身了,真的...
    希望每天睡觉不失眠阅读 1,832评论 0 0
  • 12.5……140天 【体验入】 一个人的能力很重要,可有一样东西比能力更重要,那就是人品。人品,是人真正的最高学...
    吕志萍阅读 3,043评论 0 4
  • 1.从本篇文章/音频/视频中我学到的最重要的概念 But the kindest act of all was w...
    17数418张熙阅读 3,269评论 2 0

友情链接更多精彩内容