I want to fix screen orientation on my android application to portrait. Using google, i’ve found, that this can be done by adding the following code to my manifest.xml:
<activity android:name=".LauncherActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait">
</activity>
That’s fine enough, but the problem is follows: I’ve about 15 activities now, and this number will grow. Is there any way to apply orientation to all activities at once?
I tried to use styles in a following way:
theme.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Custom" parent="android:Theme">
<item name="android:screenOrientation">portrait</item>
<item name="android:windowBackground">@drawable/launcher</item>
<item name="android:configChanges">keyboardHidden|orientation</item>
</style>
</resources>
Manifest.xml
<application ...
android:debuggable="true"
android:theme="@style/Custom"
>
//...
</application>
or
<activity
...
android:theme="@style/Custom"
>
//...
</activity>
Both the examples apply windowBackground succesfully, but screenOrientation does’t works. Any ideas?
No way. I need to repeat
in every
<activity>tag in manifest.