Sandip rana Sandip rana - 2 months ago 17
Android Question

android-studio how to set xml theme

I am using android-studio..

I am creating activity.xml file..There from the themes I choose a Light.NoTitlebar in graphical view.

And then when I run that app..It is showing the default which is in styles.xml

<style name="AppTheme" parent="android:Theme.Holo">
<!-- Customize your theme here. -->
</style>


And my Manifestfile.xml is

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


How can I change the xml theme whatever I want??

Answer

First create a custom theme,

res/values/themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="CustomTheme" parent="@style/Theme.Holo.Light">
        <!-- Customize your theme here. -->
    </style>
</resources>

And then apply this theme to any activity you want to. Just add android:theme="@style/CustomTheme" attribute to <activity> tag of manifest file.

<activity
    android:name=".YourActivity"
    android:label="activity_title"
    android:theme="@style/CustomTheme"/>