我知道如何将主题应用于整个应用程序,但是我应该在哪里将主题应用于单个活动呢?
Answers:
您可以通过将主题应用到任何活动android:theme里面<activity>清单文件中。
例如:
<activity android:theme="@android:style/Theme.Dialog"><activity android:theme="@style/CustomTheme">而且,如果您要以编程方式设置主题,则setTheme()在method内部调用setContentView()和super.onCreate()method之前使用onCreate()。
tools:context= ".YourAtivityName"根目录
                    要在Activity.java中以编程方式进行设置:
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setTheme(R.style.MyTheme); // (for Custom theme)
  setTheme(android.R.style.Theme_Holo); // (for Android Built In Theme)
  this.setContentView(R.layout.myactivity);
要在Manifest.xml中的“应用程序范围”中进行设置(所有活动):
 <application
    android:theme="@android:style/Theme.Holo"
    android:theme="@style/MyTheme">
要在Manifest.xml中的“活动”范围中进行设置(单个活动):
  <activity
    android:theme="@android:style/Theme.Holo"
    android:theme="@style/MyTheme">
要构建自定义主题,您将必须在themes.xml文件中声明主题,并在styles.xml文件中设置样式。
android:theme属性?
                    android:theme="@android:style/Theme.Holo"是添加Android内置主题的语法。  android:theme="@style/MyTheme"是用于添加styles.xml文件中描述的自定义主题的语法。在实际AndroidManifest.xml文件中,每个部分只能使用一个或另一个,不能同时使用。
                    styles.xml,然后使用语法android:theme=@style/MyBlankTheme。