自定义主题切换按钮在不同的基本主题的应用程序中

时间:2016-12-22 09:20:23

标签: android android-switch

场景#1 -------> @ style / AppTheme

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

<style name="AppBaseTheme" parent="android:Theme.Light" />

下面是我的开关 enter image description here

场景#2 -------&gt; @ style / MyMaterialTheme

我更改主题以在主屏幕上实现标签。

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/MyMaterialTheme">

<style name="MyMaterialTheme" parent="MyMaterialTheme.Base" />
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>

&安培;现在相同的Switch如下(红色椭圆形)

enter image description here

问题:如何保持标签的实施&amp;保持旧场景#1开关。我猜这是因为主题从“android:Theme.Light”变为“Theme.AppCompat.Light.DarkActionBar”

甚至可能吗?能否请你帮忙。 :)

0 个答案:

没有答案