[英]How to set App Theme programatically in Android?
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. 因此,我决定在课堂上针对该设置的父级布局ID进行编程显示透明度主题,并尝试在那里设置主题,但我无法进行设置。
Reffered many set but no use if some have idea about this please help me friends. 递了许多集,但如果有人对此有任何想法,则没有用,请帮助我的朋友。
您可以在调用setContentView(...)
和super.oncreate()
之前尝试使用setTheme(..)
super.oncreate()
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 然后转到activity.xml并在顶部栏上,设置与清单中相同的主题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.