My app stops from working for some reason when the phone is rotated to the side and so the app does too. How can I avoid this, making it so it appears only vertically? Thanks a lot
add this to your activities in android manifest :)
android:screenOrientation = "portrait">
Here is a full example:
<activity
android:name=".Activity.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
</activity>
In your app's manifest file, set activity to be vertical... Its easy...
Related
I'm using eclipse and I'm trying to figure out how to only allow a Portrait state be used during game play. I can't seem to find any options in eclipse to block the Landscape state.
I'd appreciate any assistance. I know it's probably a simple matter, but I can't seem to find it and I've not tried to do this before.
Thanks in advance.
In your AndroidManifest file you can achieve this. You will add the android:screenOrientation tag in your application declaration. Something like this
<application
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:screenOrientation="portrait" > //HERE
<activity
android:name="com.test.SomeActivity"
android:label="#string/app_name" >
You can change that to landscape as well. This attribute can also be applied to individual activities instead of the whole application if you need that.
In the activity tags of your manifest file, add this:
android:screenOrientation="portrait"
I have a simple app. And I would prefer the views stay the way they are when the orientation change. How can I do that?
Thanks in advance!
Add android:configChanges="keyboardHidden|orientation" to the activity in the manifest file..
<activity
android:name="..." android:configChanges="keyboardHidden|orientation">
</activity>
And read Handling Runtime Changes
In addition to #Nunu's answer you may wish to override onConfigurationChanged(...) to make any essential changes to your views.
You can also lock activities to portrait or landscape in the manifest.
EDIT
To lock in portrait declare your activity in the manifest like this:
<activity
android:name="com.yourpackage.YourActivity"
android:screenOrientation="portrait" />
you should check the sample application of "Multiresolution" in your android-sdk-windows /samples directory
My app is done in Titanium. I am struggling with a issue which is that when I= launch the App by keeping the device in landscape mode. Then while loading Splash screen it first goest in Landscape mode and when app finally launches Whole UI got distorted by that orientation change. I have added the below line of code in TiApp.xml
<application android:screenOrientation="portrait" android:configChanges="keyboardHidden"/>
even though its rotating. I want to stop the orientation change of that splash screen while launching. Any idea?
In each activity you have to write
<activity android:name=".MainActivity" android:configChanges="keyboardHidden|orientation" android:screenOrientation="landscape" />
Hope it help!!
Try this. Add you custom androidManifest.xml For custom xml
and add this line in androidManifest.xml and run I think this is very useful for you.
<activity android:configChanges="keyboardHidden" android:name="org.appcelerator.titanium.TiActivity" android:screenOrientation="portrait"/>
<activity android:configChanges="keyboardHidden" android:name="ti.modules.titanium.ui.TiTabActivity" android:screenOrientation="portrait"/>
Cheers
I want to lock horizontal view in my app, is it possible?
Help is highly appreciated,
Thanks,
Use android:screenOrientation="landscape" attribute for your activity.
add this code in your menifest...
<activity android:name=".activity"
android:configChanges="orientation" android:screenOrientation="portrait"></activity>
For new android Studio 3 and above
you need to put these lines in AndroidManifest.xml code if you want to set the orientation to portrait
One thing this is sensor portrait, means both upside - downside will work.
But if you only want to put portrait for upside then, replace sensorPortrait to portrait
<activity
android:name=".MainActivity"
android:configChanges="orientation"
android:screenOrientation="sensorPortrait"
tools:ignore="LockedOrientationActivity">
Same goes for only landscape too
just one parameter change portrait to landscape
<activity
android:name=".MainActivity"
android:configChanges="orientation"
android:screenOrientation= "sensorLandscape"
tools:ignore="LockedOrientationActivity">
Hey all - I have tried to only display my app in portrait view orientation to no avail.
I have the code: android:screenOrientation="portrait" in every button, ImageView, TextView, etc... in my xml files but when I tilt the phone to the side, it still goes into landscape view.
I do call the camera in my app, but I don't think that is the issue - any thoughts?
the layout is the wrong place. you have to place it in the activity like this:
<activity android:screenOrientation="portrait" ...>
Force an Android activity to always use landscape mode
is google that hard to understand? google "android force portrait" and the first four links shows the answer... (sorry.. just had to let it out :) )
You have to put the android:screenOrientation="portrait" in the AndroidManifest.xml.
In AndroidManifest.xml you have to do something like this:
<activity android:name=".Your_Activity_Name"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"/>