What is the main purpose that in an Android application you can specify theme both in AndroidManifeset.xml and in the actual activity xml?

Viewed 17

Why can you specify android:theme tag both in AndroidManifeset.xml in the Activity part and in the actual activity xml, like in my Manifest by the secondactivity as I added Translucent theme?

In Manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.transparentactivity">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".SecondActivity"
            android:label="@string/title_activity_second"
            android:theme="@style/Theme.AppCompat.Translucent">
        </activity>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

..or in second activity:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:theme="@style/Theme.AppCompat.Translucent"
    tools:context=".SecondActivity">
    <Button
        android:layout_marginTop="200dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Hello">
    </Button>
</RelativeLayout>

In this case the theme specified in second_activity won't be even applied but when I add it to the Manifest, to the second activity part than it works. So the place of the definition result in different behavior. I can accept that but I would like to know whene is it useful specifying theme in the activity xml instead of the Manifest.

Thank you!

0 Answers
Related