0

Now I am going on with app theme transparency that is i have one class.

I have two button options if user click one button it should load app theme and for other one transparency should load.

So i decided to show transparency theme progrmatically for that set parent layout id in class and tried to set the theme there but i can't able to set.

Reffered many set but no use if some have idea about this please help me friends.

Vicky
  • 921
  • 1
  • 11
  • 33
  • possible duplicate of [Switching application-wide theme programmatically?](http://stackoverflow.com/questions/4663752/switching-application-wide-theme-programmatically) – 2Dee Sep 10 '14 at 15:21

2 Answers2

1

You can try using setTheme(..) before calling setContentView(...) and super.oncreate()

erad
  • 1,766
  • 2
  • 17
  • 26
1

Go in manifest file:

First set theme for all application:

    <application
            android:name=".MyApplication"
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" > <!--Your theme-->
      ...

You can set Theme for every activity

    <activity
        android:name=".activities.FirsActivity"
        android:label="@string/title_activity_firsactivity"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.Holo.Light.NoActionBar"> <!--Your theme for this activity-->
    </activity>

    <activity
        android:name=".activities.SecondActivity"
        android:label="@string/title_activity_secondactivity"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.Holo.Light.NoActionBar"> <!--Your theme for this activity-->
    </activity>

And go to activity.xml and on top bar ,set same theme like in manifest

MilanNz
  • 1,323
  • 3
  • 12
  • 29
  • Now I am going on with app theme transparency that is i have one class. I have two button options if user click one button it should load app theme and for other one transparency should load. – Vicky Sep 10 '14 at 16:02
  • Create two themes in style, and in your java.class write samthing like that: if(true){setTheme( android.R.style.ThemeFirst ); } else { setTheme( android.R.style.ThemeSecond ); } – MilanNz Sep 10 '14 at 16:09