2

If i have specified my Theme for the application such as so:

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

Do I then need to specify the Theme again for each activity defined in the manifest file like so:

<activity
        android:name="main_application.MainActivity"
        android:label="@string/app_name" >
        android:theme="@style/AppTheme" >
    </activity>

Or do i only need to do this when over riding the applications theme for a single activity?

4

4 回答 4

4
Do I then need to specify the Theme again for each activity defined in the manifest file like so

No, Once you have defined the Theme for the application and applied it in manifest <application> tag then there is not need of specifying Theme for each Activity again.

But if you want different Themes for each activity then in this case you can define separate themes for each activity.

于 2013-10-18T14:46:02.337 回答
3

Do I then need to specify the Theme again for each activity defined in the manifest file like so

No. If you need a specific Theme for a particular Activity then you can set it on the Activity. Otherwise just set it on the <application>

Activity and Application Themes

于 2013-10-18T14:39:16.680 回答
2

If you want to use same theme all over the application then setting theme in application tag in manifest is good enough. For example, this part of your code

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

But if you want to use different theme in different activities then you have to specify the theme like your code

<activity
   android:name="main_application.MainActivity"
   android:label="@string/app_name" 
   android:theme="@style/ThemeForThisActivity" /> 
于 2013-10-18T14:41:32.947 回答
0

If you need different theme for each of your activity then YES. If you need same theme for your application then NO.

于 2013-10-21T12:07:55.837 回答