简体   繁体   中英

Strange behavior of styles (Themes) in Android

I got this styles for my Android app:

<resources>

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

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@color/background_new</item>
    <item name="android:textColorPrimary">@color/colorAccent</item>
    <item name="android:textColorHint">@color/colorAccentHint</item>

    <!-- Customize your theme here. -->
</style>

<style name="MyToolBar" parent="Widget.AppCompat.ActionBar">
    <!-- Support library compatibility -->
    <item name="android:textColorPrimary">@color/colorAccent</item>
    <item name="android:textColorSecondary">@color/colorAccent</item>
    <item name="colorControlNormal">@color/colorAccent</item>

</style>

<!-- Custom searchView may be used or not-->
<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView">
    <!-- Gets rid of the search icon -->
    <item name="searchIcon">@null</item>
    <!-- Gets rid of the "underline" in the text -->
    <item name="queryBackground">@null</item>
    <!-- Gets rid of the search icon when the SearchView is expanded -->
    <item name="searchHintIcon">@null</item>
    <!-- The hint text that appears when the user has not typed anything -->
    <!--<item name="closeIcon">@null</item> -->
</style>

<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
    <item name="tabTextAppearance">@style/MyCustomTabText</item>
</style>

<style name="MyCustomTabText" parent="TextAppearance.Design.Tab">
    <item name="android:textSize">12sp</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="NavDrawerTextStyle" parent="Base.TextAppearance.AppCompat">
    <item name="android:textSize">12sp</item>
</style>

<style name="MyCheckBox" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorControlNormal">@color/colorPrimaryTransparent</item>
    <item name="colorControlActivated">@color/colorAccent</item>
</style>

<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:textColorPrimary">@color/colorAccent</item>
    <item name="android:background">@color/background1</item>
    <item name="android:buttonStyle">@style/MyApp.BorderlessButton</item>
</style>

<style name="MyApp.BorderlessButton" parent="@style/Widget.AppCompat.Button.Borderless">
    <item name="android:textSize">12sp</item>
</style>

<style name="MyRadioButton" parent="Theme.AppCompat.Light">
    <item name="colorControlNormal">@color/colorAccent</item>
    <item name="colorControlActivated">@color/colorAccent</item>
</style>

Normally i have transparent background on Toolbar of NavigationDrawler menu items click.

But sometimes theme in my app changes to Holo theme , and i can figure it out when its happens , so when i press menu items in Toolbar or in NavigationDrawler their background become blue, like in Holo theme

Where i have mistake and why its happens?

Can you publish your Android Manifest ? Maybe some activities override the base application style ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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