user1841702
user1841702

Reputation: 2763

Android- changing theme in specific Activity

The base theme for my app is:

<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
        <item name="android:actionBarTabBarStyle">@style/MyActionBarTabBar</item>
        <item name="android:actionBarTabStyle">@style/MyActionBarTabView</item>
        <item name="android:popupMenuStyle">@style/MyMenu</item>
        <!--<item name="android:actionBarStyle">@style/window_action_bar_style</item>-->
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>

and I would like to apply this theme to just one activity.

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

However when I do this, I am unable to access the SwitchCompat widget in that activity:

<android.support.v7.widget.SwitchCompat/>

What am I doing wrong here ? Any suggestions or a solution would be most appreciated. The problem occurs when I try to override the base theme in a particular activity and try to access the SwitchCompat widget. My project is already quite large for me to change my base theme for the entire application as I will have to make changes to the ActionBars and other views. How can this be solved ?

Upvotes: 3

Views: 7713

Answers (1)

Kabir
Kabir

Reputation: 1479

Just use your custom theme like this in AndroidManifest.xml

<activity
    android:name=".SignupActivity"
    android:label="@string/title_activity_signup"
    android:theme="@style/SignupTheme">
</activity>

Upvotes: 13

Related Questions