hasher13
Android Fan
Profile
Posts: 376
Reg: Jul 21, 2012
Wethersfield
8,060
02/24/13 08:52 AM (12 years ago)

Prevent rotation

Good morning. I tried to search the forum for this but it looks like everything is pertaining to IOS. Does anyone know how to prevent the screen rotation for Androids? I have changed the core properties, but that did not work. Thanks in advance, Howard
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
02/24/13 08:56 AM (12 years ago)
On a screen by screen basis, you can add this code to the relevent .java file: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); (You'll probably need to import the ActivityInfo). It can go straight after the reference to base layout, eg: LinearLayout baseView = (LinearLayout)findViewById(R.id.baseView); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); (or LANDSCAPE)..
 
hasher13
Android Fan
Profile
Posts: 376
Reg: Jul 21, 2012
Wethersfield
8,060
like
02/24/13 09:09 AM (12 years ago)
Hi Raveyd, Not really sure on how to or where exactly to import this in the screen .java file. Working with custom url screen. Thanks, Howard
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
02/24/13 09:25 AM (12 years ago)
ok, on around line 86 of the BT_screen_customURL.java file (src > package name > BT_screen_customURL.java) is this line: //reference to base layout.. LinearLayout baseView = (LinearLayout)findViewById(R.id.baseView); add the orientation code underneath it: //reference to base layout.. LinearLayout baseView = (LinearLayout)findViewById(R.id.baseView); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); There should be a red squiggle underneath ActivityInfo. Hover your mouse over the squiggle and it should prompt you to "Import ActivityInfo".
 
hasher13
Android Fan
Profile
Posts: 376
Reg: Jul 21, 2012
Wethersfield
8,060
like
02/24/13 09:43 AM (12 years ago)
HOLY COW!! yes, I meant to do that in caps. It worked!! not only did it not change the orientation, but importing the code and your awesome directions made it so easy! I know it might be simple to others, but I did learn some new stuff which I enjoy. Now off to next problem, how to have the app enlarge or fit to larger devices like tablets, any suggestions on that. I saw possibly changing the SDK=9 would do it. Any thoughts on this. thanks again, Howard
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
02/24/13 01:25 PM (12 years ago)
Excellent! I'm slowly learning a bit more with android too. Some of it's enjoyable.. I got some menu buttons spinning around and others shooting off the screen today, which was quite neat. Next problem.. not so much help.. BT/Android handle screen resizing pretty well. Personally, for example, I quite like the tabbed layout on a phone and on a tablet, no code tweaking needed beyond the bt defaults.
 

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.