首页 > 解决方案 > Android Studio-Designer 不显示颜色作为模拟器/手机

问题描述

模拟器(和设备)上的字符串下划线为绿色,但在设计器窗口上为灰色。style 和 colors.xml 中没有自定义颜色。那么为什么颜色不一样呢?

结果

清单.xml:

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

    <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="com.example.myfirstapp.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.example.myfirstapp.DisplayMessageActivity"
            android:parentActivityName="com.example.myfirstapp.MainActivity">
            <!--The meta-data tag is required if you support API level 15 and lower -->
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.myfirstapp.MainActivity"/>
        </activity>
    </application>

</manifest>

颜色.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!--<color name="colorPrimary">#087609</color>
    <color name="colorPrimaryDark">#002900</color>
    <color name="colorAccent">#327f4f</color>-->
</resources>

样式.xml:

<resources>

    <!-- Base application theme. -->

    <style name="AppTheme" parent="Theme.AppCompat">
        <!-- Customize your theme here. -->

        <!--<item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        -->
    </style>

</resources>

清单.xml

颜色.xml

样式.xml

PS:抱歉链接上的图片 - 我没有足够的声誉直接发布图片。

标签: android-studiocolorsdesigner

解决方案


嗯......它在设计器窗口中是灰色的,因为它在那里没有活动(显然)并且它在模拟器中是青色的,因为它是 Android 的默认强调色。尝试更改colorAccent值以将默认颜色更改为其他颜色


推荐阅读