Reputation: 433
For my App, I need to fix the orientation to portrait on Phones and allow portrait and landscape on Tablets. I have looked at answers here and but I want to try to do the same using xml alone. I tried adding the following line in my manifest
<activity
android:theme="@style/Theme.ActionBarLargeTitle"
android:name="com.work.activities.MyActivity"
android:screenOrientation="@integer/orientation_supported"
android:exported = "false"/>
In res/values/dimens.xml I added the following line (1 corresponds to portrait)
<integer name="orientation_supported">1</integer>
I have created another file, res/values-sw600dp/dimens.xml in which I have added (-1 corresponds to unspecified)
<integer name="orientation_supported">-1</integer>
On phone this code works fine and the Activity is always in portrait mode. On Nexus 10" Tablet(width 800dp) this fails and it is fixed in portrait mode. Is there anything wrong with this approach?
EDIT: I have checked with various values and in all cases(in all devices) the value from res/values/dimens.xml is picked up. If this value is missing there is an error when the app is installed 'Installation error: INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION'.
Upvotes: 1
Views: 294
Reputation: 22232
There are two possible problems here:
TextView
.Upvotes: 0
Reputation: 38585
The issue is you are using -sw600dp
qualifier, which doesn't actually check orientation but rather checks that the shortest side is at least 600dp. Try using -land
or -port
qualifiers instead.
Upvotes: 1