Lock Horizontal View - android

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">

Related

how can I disable landscape mode javafx?

I want to disable landscape modeon javafx app for the whole app. How can I do that?
I'm also using Gluon plugin.
Thanks in advance
On Android by default you have enabled changes between portrait and landscape orientations.
If you want just portrait orientation, you can set this on the AndroidManifest.xml file under src/android/:
<activity android:name="javafxports.android.FXActivity"
android:label="<yourAppName>"
android:screenOrientation="portrait"
android:configChanges="orientation|screenSize">
...
</activity>
Add this line to your AndroidManifest.xml under the activity tag:
android:screenOrientation="portrait"

Screen orientation changes when unlock the device

I have an application in landscape orientation. This is how the manifest looks like:
<activity
android:name="Activity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:configChanges="keyboardHidden">
</activity>
When I lock and unlock the device the orientation changes to portrait for half of second and then goes to landscape. I noticed that this is not happening on all devices. I could reproduce it on Samsung Galaxy SI.
Any ideas what can it be?
Adding "orientation|screenSize" to configChanges does not fix the issue.
EDIT:
Basically, the layout is losing its orientation when I slide the unlock screen(specially on Samsung devices) because it's taking the orientation of the slide activity which is portrait.
Changing the name of the layout folder to "layout-land" may fix this by only allowing drawing in landscape
You need to add the below properties in the activity tag of manifest you want,,,rather than adding your application tag
<activity
android:name="com.example,MainActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustPan" >
</activity>
Or if this do not work,,, then add this code just below the setContentView() in your Activity
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

setRequestedOrientation doesn't lock the orientation

I am trying to lock an activity to landscape mode and have an overlying activity receive and use the orientation changes. The top activity is partly transparent so it is important that the bottom activity locks and is displayed correctly. I have tried to set it programatically with setRequestedOrientation() and in the AndroidManifest.xml with android:screenOrientation="landscape"
When I lock the orientation using the manifest the top activity also locks. When I add android:configChanges="orientation|screenSize|keyboardHidden" the top activity changes orientation but so does the bottom activity. Sometimes the bottom activity goes completely blank (transparent) after the orientation changes.
This is in my AndroidManifest.xml:
<application
android:debuggable="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:theme="#style/AppTheme"
android:screenOrientation="landscape"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TopActivity"
android:screenOrientation="sensor"
android:configChanges="orientation|screenSize|keyboardHidden"
android:theme="#style/Theme.Transparent">
</activity>
</application>
MainActivity is the bottom activity. How do I properly handle the orientation changes so that the single activities are locked the way I set them to?
just add screenOrientation to the activity which you don't want to rotate on orientation change in the manifest file like this:
<activity android:name=".Activity"
android:screenOrientation="portrait" />
All other activities will automatically rotate on orientation change.
No need to give screenOrientation for other activities.
1) To disable orientation (i.e. to prevent Android from restarting your activity if the user flips the phone), then specify "configChanges" in your AndroidManifest (like you're already doing, apparently), and then simply don't respond to any changes:
<activity android:name="MainActivity" android:configChanges="keyboardHidden|orientation|screenSize">
2) Alternatively, let's say you want to force your app to "landscape" mode. Instead of "configChanges", you can specify "screenOrientation"
<activity android:screenOrientation="landscape" ... >
3) Finally, if you want to handle the orientation change, you'll need to a) save state, then b) do whatever processing you need (including, perhaps, notify other activities):
http://developer.android.com/guide/topics/resources/runtime-changes.html

Orientation Changes distorted the View in Android device

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

Stopping orientation change with side-keyboard (Android)

I am wondering how I can make the orientation of the screen permanent, even when the phone has a slide-out keyboard. This is the code I have:
<activity android:name=".AppName" android:label="#string/app_name"
android:screenOrientation="portrait">
Thanks.
Try adding:
android:configChanges="orientation|keyboardHidden"

Categories

Resources