将configChanges应用于每个活动还是以编程方式应用?

时间:2019-03-28 03:04:45

标签: android

我想应用主题,所以我在Application或Some Activity标签上引用了它,但是在Application标签或Activity标签上都起作用了。我该如何申请? Mainifest.xml:

 <application
    android:name=".base.CustomApplication"
    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/Activity_Base_Setting">

    <!-- android key -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key"/>
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version"/>
    <meta-data
        android:name="android.max_aspect"
        android:value="2.1"/>

    <activity
        android:configChanges="orientation|screenSize|keyboard"
        android:name=".ui.activity.MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/Activity_Base_Setting">
    </activity>
    <activity
        android:noHistory="true"
        android:name=".ui.activity.SplashActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>

values / styles.xml

<style name="Activity_Base_Setting" parent="AppTheme">
    <item name="android:launchMode">singleTop</item>
    <item name="android:configChanges">screenSize|keyboard|orientation</item>
    <item name="android:screenOrientation">portrait</item>
</style>

我不想这样写,

  <activity
        android:screenOrientation="portrait"
        android:configChanges="orientation|screenSize|keyboard"
        android:launchMode="singleTop"
        android:name=".ui.activity.MainActivity">

0 个答案:

没有答案