Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 9    Views: 153

dudave
Android Fan
Profile
Posts: 111
Reg: Mar 23, 2011
Israel, Netanya
1,110
03/17/13 12:47 AM (11 years ago)

Preventing landscape rotation on a selected screen (android)

Hi there, been reading all the discussions about preventing rotation on android but wasn't able to make it work on my app. i tried to put android:screenOrientation="portrait" on several different places in my manifest but non worked out. additionally i was wondering if it is possible to prevent the rotation on one specific screen only and not the all App. Thanks David
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
03/17/13 01:55 AM (11 years ago)
Yes it is possible to prevent a particular screen from being rotated in landscape mode. You have to set the orientation to portrait for each particular screen that you want to be viewed only in portrait mode. Adding this code is correct- android:screenOrientation="portrait" but i think you dont know where to put it exactly. Look for this following comment in the manifest file- <!-- remaining activities are for individual plugin types --> Below this commented line you will find all the activities related to other plugins. So if you wnat to prevent the custom html screen from being viewed in landscape you will have to add the android:screenOrientation="portrait" like this--- <activity android:name=".BT_screen_customHTML" android:configChanges="keyboardHidden|orientation" android:label="@string/app_name" android:screenOrientation="portrait" > </activity>
 
Suvinay pawa
buzztouch Evangelist
Profile
Posts: 599
Reg: Aug 01, 2012
location unknow...
9,890
like
03/17/13 04:07 AM (11 years ago)
@sandeep what you just said will do for a specific plugin if he wants custom html to be rotated in one screen and not in other , than this will not be useful so he has to clone the plugin..
 
dudave
Android Fan
Profile
Posts: 111
Reg: Mar 23, 2011
Israel, Netanya
1,110
like
03/17/13 04:51 AM (11 years ago)
this is what i did and it didn't work: <activity android:name=".BT_screen_menuButtons" android:label="@string/app_name" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation"></activity> i was aiming for the menu button wich is my home page...
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
03/17/13 07:48 AM (11 years ago)
Using the manifest never seems to work for me, it's supposed to though... So I add code to the java files instead. Find this line in the onCreate of the screen you want to set: LinearLayout baseView = (LinearLayout)findViewById(R.id.baseView); and below it add: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); (or LANDSCAPE) There will probably be a red line under 'ActivityInfo', hover your mouse over it and it'll prompt to add the import. Add the import, save, do a Project > Clean and it should be good to go.
 
dudave
Android Fan
Profile
Posts: 111
Reg: Mar 23, 2011
Israel, Netanya
1,110
like
03/17/13 08:04 AM (11 years ago)
Thank you raveyd! it worked perfectly! finally i don't have to try and make all of my pages fit both portrait and landscape, i'm a happy man! :) :) :) David
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
03/17/13 08:46 AM (11 years ago)
Excellent news!
 
dudave
Android Fan
Profile
Posts: 111
Reg: Mar 23, 2011
Israel, Netanya
1,110
like
03/17/13 09:48 AM (11 years ago)
double post
 
KRima
Apple Fan
Profile
Posts: 154
Reg: Jan 27, 2013
Sydney
1,940
like
03/17/13 09:55 PM (11 years ago)
@raveyd. I only use plugins and i would also like to make some of my screens portrait only in my app. In Xcode, where can i do this to the app screen? Say i have a menu button plugin as my home screen. I dont want it to be rotated only the pages that come after.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
03/18/13 05:57 AM (11 years ago)
Sorry @KRima, I don't know a thing about Xcode!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.