将主题在Android的活动?主题、Android

2023-09-12 09:45:30 作者:夏北岛

我知道如何将主题应用到整个应用程序,但在那里我会去一个主题应用到只是一个单一的活动?

I know how to apply a theme to a whole application, but where would I go to apply a theme to just a single activity?

推荐答案

您可以将主题通过包括安卓应用到任何活动<活性GT; 里面清单文件

You can apply a theme to any activity by including android:theme inside <activity> inside manifest file.

例如:

&LT;活动机器人:主题=@安卓风格/ Theme.Dialog&GT; &LT;活动机器人:主题=@风格/ CustomTheme&GT; <activity android:theme="@android:style/Theme.Dialog"> <activity android:theme="@style/CustomTheme">

如果你想设置主题编程,然后使用 setTheme()之前调用的setContentView()和 super.onCreate()办法()方法。

And if you want to set theme programatically then use setTheme() before calling setContentView() and super.onCreate() method inside onCreate() method.