Android中样式(主题)的奇怪行为

时间:2016-06-08 20:42:39

标签: android themes android-toolbar android-theme android-styles

我为我的Android应用程序设置了这个样式:

<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>

通常我在 NavigationDrawler 菜单项的工具栏上有透明背景点击。

但有时我的应用中的主题会更改为 Holo主题,我可以在发生时将其弄清楚,所以当我在工具栏 NavigationDrawler 他们的背景变为蓝色,如 Holo主题

我有错误,为什么会发生错误?

1 个答案:

答案 0 :(得分:0)

您可以发布Android Manifest吗?也许有些活动会覆盖基础应用程序样式?