簡體   English   中英

Android中樣式(主題)的奇怪行為

[英]Strange behavior of styles (Themes) in Android

我的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主題中一樣

我在哪里出錯,為什么會出錯?

您可以發布Android清單嗎? 也許某些活動會覆蓋基本應用程序樣式?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM