简体   繁体   English

为什么我无法将应用程序的主题更改为HOLO.DARK?

[英]Why am I not able to change the theme of my app to HOLO.DARK?

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="Zine"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" parent="android:Theme.Holo" >

    <activity android:name=".SplashScreen">
        android:label="@string/Zine" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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









    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

this is my Androidmanifest.xml 这是我的Androidmanifest.xml

Now this is the app screen: 现在这是应用程序屏幕:

I have selected the holo dark theme yet I am not getting black color on screen. 我选择了整体深色主题,但屏幕上没有黑色。 Instead, I am getting the default theme. 相反,我正在获取默认主题。 How do I fix this? 我该如何解决?

Do this In your Code.. Working Fine 在您的代码中执行此操作。

Also Your Error Reason 也是你的错误原因

The reason you are having this problem is because you are extending the activity with you are trying to apply the dialog theme to is extending AppCompatActivity which requires the AppCompat theme to be applied. 您遇到此问题的原因是因为您在尝试将对话框主题应用到扩展活动时是在扩展AppCompatActivity,而这需要应用AppCompat主题。

Change the Java inheritance from AppCompatActivity to Activity and leave the dialog theme in the manifest as it is. 将Java继承从AppCompatActivity更改为Activity,然后将对话框主题保留在清单中。

Set in Androidmanifest.xml 在Androidmanifest.xml中设置

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Zine"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity android:name=".SplashScreen">
    android:label="@string/Zine" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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

<activity android:name=".MainActivity">
    <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.DEFAULT" />
</activity>

In You styles.xml 在您中styles.xml

<!-- Base application theme. -->

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

</resources>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM