What are the requirements for landscape layout to work? - android

So basically I created different xml layout for landscape mode, put it into folder res/layout-land, kicked off an emulator, pressed CTRL + F12 to change emulator's mode to landscape, started my app and ooops it still doesn't work. It still shows off in the portrait mode. What are other requirements to make this going. Do I have to tinker with R.java or activity's code onCreate ?

Hit Left Ctrl + F12 , or Home, or PageUp, (not NUMPAD 7 or NUMPAD 9 like the website says) to rotate emulator.

Related

Hardware buttons is not clickable in Android emulator

I work in Android Studio 1.0 RC 2 and I have an Android Emulator with Intel HAXM. The emulator is running normally. It shows the hardware buttons, but this buttons is not clickable. The AVD configuration is default for Nexus S, but it's scale is 0.5.
It shows the hardware buttons, but this buttons is not clickable
If it shows HOME and BACK in the navigation bar, then they are not "the hardware buttons". That is the navigation bar. For actual "hardware" HOME and BACK buttons, you should not see anything, and the are mapped to Home and Esc respectively on your development machine's keyboard.
Go into the actual configuration file for your AVD. On OS X and Linux, that normally is ~/.android/avd/.../config.ini, where ... is based on the name of your AVD. See what your hw.mainKeys value is. For "hardware" HOME and BACK buttons, hw.mainKeys should be yes; for a navigation bar with HOME and BACK buttons, hw.mainKeys should be no.
Based on #CommonsWare comment
#Plugie: I never use those skins, and I am not aware that those buttons are ever supposed to be clickable.
I recommend to set hw.mainKeys=no
Go into the actual configuration file for your AVD. On OS X and Linux, that normally is ~/.android/avd/.../config.ini, where ... is based on the name of your AVD. See what your hw.mainKeys value is
After set hw.mainKeys=no, it will show System Bar which can be seen in screen shoot which red rectangle. Then you can navigate BACK, HOME using System Bar instead of Hardware Button
You'll probably need to change some of your emulator settings in order to do that. Change the skin to 'Skin with dynamic hardware controls' and make sure the 'hardware keyboard present' checkbox is checked. Not sure if this is the solution, but give it a try.
For me it required a little more work. In short, avd creates android image incorrectly, setting dPad and mainKey to "no". This post helped
http://ridz1ba.blogspot.ru/2012/12/android-virtual-devices-avd-problem-on.html
Beware that the emulator of Lollipop or Jellybean doesn't auto update the display (tested on Chipmunk) so pressing any buttons will look like they are not clickable unless you refresh the display by clicking other tabs such as Device Manager. I run Marshmallow (x86_64 Google APIs on Chipmunk) and all buttons respond to click.

How to maximize logcat's windows on android studio?

The title said it all,
How to maximize logcat's windows on android studio?
Right now my logcat's windows is very small and i need to scroll it to view it's message.
Thanks
You can use the resize pane handles to make it bigger, or use the settings option (a cog icon on the right of the DDMS pane) to choose floating mode, and maximise that window.
I have indicated all the trivial steps to be sure to fit every preset configuration of Android Studio, once implemented will take roughly 200 milliseconds to maximize Logcat!
The document is divided in Settings( to do only one time) and then The real shortcut ( to do once the settings are in memory):
Settings:
1)Alt+6 to open the Android debug window( you do not need this step if you are in the middle of the debugging, namely if you pressed the debug button)
2)Drag with the mouse the tab logcat putting it in front of the others( probably ADB logs, Memory, CPU for android studio 1.3.1), in this way the system will remember this preset.
The real shortcut:
When you are in debug mode, press Alt+6 (in the case Logcat is not appearing as main table),and CTLR+SHIFT+quote where quote means the " Quote Key
LOGCAT will be maximized, to switch to debug alt+5, no need to press again Ctrl+Shift+Quote! Please notice that if it is set Debug only this application from the dropdown menu you won't see a lot of events, so it is up to you to decide to select No Filters (if you want to see the Error only,Tab in the Dropdown menu where is written Verbose and change it with Error.)
All in all once the settings are correct Alt+6-->Ctrl+Shift+Quote( to maximize)-->Alt+5 to go back on the debugger table
EDIT: There is a second possibility depends by your taste: from the main Debug screen ( Table Debugger) you can press Ctrl+Shift+Quote then the key TAB, and then Arrow Right, Left to switch between Logcat,Debugger and Console. Personally I use this option only when I have a long debug because is useful to switch between Debugger and Logcat with Alt+Arrow
Even better (on OS X at least, perhaps others?): SHIFT-COMMAND-' toggles maximize / minimize

Android ICS Launcher 4.0.x cannot keep screen orientation

I've got a strange case for Android ICS Launcher 4.0.x.
Pre-condition:
A ICS device with root permission
Download Android ICS Launcher 4.0.3/4 source code (to modify and run)
Procedure:
Go to market (Play Store), download "Go Task Manager"
Open Widgets tab on Launcher, find "Mem Optimize", drag to Home screen (workspace)
Download and install "Fruit Ninja"
Create "Fruit Ninja" shortcut next to "Mem Optimize" widget on Home screen.
Execute "Fruit Ninja" and keep your phone in LANDSCAPE (hold it in your hand in this position, don't change this)
On menu screen of "Fruit Ninja", slice "Exit" , select "Yes"
Now back on Launcher Home screen, touch on "Mem Optimize" widget
Current Result:
After step 7, the screen is rotated to LANDSCAPE for a while and return to PORTRAIT.
Expectation:
After step 7, the screen should be kept in PORTRAIT.
My Tries (modify Launcher ICS source code):
Add to "Manifest.xml": android:screenOrientation="portrait" => still can't fix the problem.
Handle configuration change, android:configChanges="orientation|screenSize" => still can't fix the problem.
Use: setRequestedScreenOrientation(PORTRAIT) => still can't fix the problem.
What I've tried worked on Android 2.x; however, from 4.0.3+ , somehow it's not working as expected. Does anyone have any idea about this?
The problem is not in the Launcher. The problem is that a single configuration ( and that includes the orientation) is shared among all activities on the phone.
So if you have an activity that set the orientation to Landspace,e.g. Camera ( this is classical example where I work), this will "make" all the other activities to be on landscape too, because as I said that information is unique in system and shared among all.
This happens since the beginning of Android albeit sometimes you will not notice that because the changes are pretty fast.
To check what I am saying do the follow. Write an activity with a dialog theme such as #android:style/Theme.Holo.Dialog, so it won't cover the entire screen and you'll still be able to see the activity that was bellow. That activity must have a fixed orientation. Let's say that you set it to landscape. Then use am start on Android shell to be able to start the activity you have just created on top of any other activity. You'll see that no matter the orientation that previous activity had, as soon as you launch you test activity, the previous activity will assume the same orientation than your test activity. When you hit back, the previous activity will restore the orientation. But sometimes it might take a while, so you see things like your current result.
The stock ICS launcher has a few places where it will set the orientation to unspecified. Just search Launcher.java for setRequestedOrientation, but specifically it's either on "eng" builds or tablets. It does it in onCreate but also after a drag/drop from the appscustomize.
From Launcher.java's onCreate:
// On large interfaces, we want the screen to auto-rotate based on the current orientation
if (LauncherApplication.isScreenLarge() || Build.TYPE.contentEquals("eng")) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}

Android Application Layout

Hi does anyone know how to implement a layout change in the application. For example, when a user sees a text box prompt and turns the phone sideways and views the application as a landscape view. I have no idea how to go forward with this?
May I add that I know I have to create a layout-land xml. I'm ok with that bit, it's just I'm not sure how to make the phone automatically detect that it is oriented sideways and needs to implement the landscape view.
Many thanks.
If the phone supports orientation changes and you've turned it on in Settings (Display > Auto-rotate screen) everything should work automatically. The Activity will be restarted and the correct layout file used.
See this post here för details: Android: alternate layout xml for landscape mode

Switching to landscape mode in Android Emulator

This is probably a pretty easy to answer question, but I can't find the solution myself after a couple hours of searching the documentation and Google. I set the orientation of my Android app to landscape in the AndroidManifest.xml file:
android:screenOrientation="landscape"
However, when I run the app in the simulator, it appears sideways and in portrait mode. How can I switch the emulator to landscape mode on a mac? It's running the 1.6 SDK.
Try:
ctrl+fn+F11 on Mac to change the landscape to portrait and vice versa.
left-ctrl+F11on Windows 7.
ctrl+F11on Linux.
For Mac users, you only need to use the fn key if the setting "Use all F1, F2 etc. keys as function keys" (under System Preferences -> Keyboard) is checked.
left-ctrl+F11on Windows 7
It works fine in Windows 7 for android emulator to change the landscape orientation to portrait and vice versa.
Not sure about your question - "sideways" is the same as "landscape".
If you mean how to switch during runtime:
Switch to previous layout orientation (for example, portrait, landscape):
KEYPAD_7, Ctrl + F11
Switch to next layout orientation (for example, portrait, landscape):
KEYPAD_9, Ctrl + F12
From docs.
Just use 9 in numeric keyboard with num-lock off.
7 rotates in the opposite direction.
Android Emulator Shortcuts
Ctrl+F11 Switch layout orientation portrait/landscape backwards
Ctrl+F12 Switch layout orientation portrait/landscape forwards
Main Device Keys
Home Home Button
F2 Left Softkey / Menu / Settings button (or PgUp)
Shift+F2 Right Softkey / Star button (or PgDn)
Esc Back Button
F3 Call/ dial Button
F4 Hang up / end call button
F5 Search Button
Other Device Keys
Ctrl+F5 Volume up (or + on numeric keyboard with Num Lock off) Ctrl+F6 Volume down (or + on numeric keyboard with Num Lock off) F7 Power Button Ctrl+F3 Camera Button
Ctrl+F11Switch layout orientation portrait/landscape backwards
Ctrl+F12 Switch layout orientation portrait/landscape forwards
F8 Toggle cell network
F9 Toggle code profiling
Alt+Enter Toggle fullscreen mode
F6 Toggle trackball mode
Ctrl+F11 or Ctrl+F12 to change the orientation of the android emulator on windows
It will cost 4 hours of researching. Don't forget enable auto-rotation in your virtual devices!
This is now much more intuitive. The AVD interface now includes a sidebar with various functional shortcuts. The buttons circled in blue will rotate the device clockwise and counterclockwise on the screen.
On iMac with long keyboard (keyboard with numeric keypad at the right):
(1) Cmd + 7 (on numeric part of keyboard)
(2) Cmd + 9 (on numeric part of keyboard)
I'm using Android Studio and none of the suggestions worked. I can turn the emulator but it stays in portrait. I didn't want to add a command in the manifest forcing landscape. The fix for me was:
turn the emulator to landscape mode using ctrlF11 (the image will still be in portrait though)
Open up the camera in the os, it opens up in landscape mode, the only app that does this
without doing anything else, debug my app from Android Studio and now it shows up in landscape
I have found that sometimes the CTRL + F11 combination just doesn't do it for me.
I have solved it by disabling the keyboard input in the emulator settings.
To do that, go to your emulator settings, klick the "show advanced settings" button and scroll all the way down. Then, disable the "enable keyboard input" option.
After doing that, try to start your emulator again, and the CTRL + F11 combination should work.
Just a little bug (Bug for me) I found on mac emulator.
On changing the orientation to landscape (CtrlCmdF11) it changes to landscape but content shows in portrait format.for that:
Go to emulator: Settings-> Display->When device is rotated->Rotate the contents of the screen
Here are some ways to move landscape on Android Emulator:
1. Mac:
Ctrl + Fn + F11
Keypad 7 or Keypad 9
Ctrl + F12 or Ctrl + Fn + F12
Command + 7 or Command + 9
2. Windows:
Left Ctrl + F11 or Ctrl + F12
3. Linux:
Ctrl + F11
4. Android studio :
We can write screenOrientation = "landscape" in the androidManifest.xml file.
5. Keyboard:
in side the emulator, turn off the Num-Lock and press Keypad 7 and Keypad 9.
6. Emulator:
click the rotate button on the screen shown below.
click the rotate button on the screen shown below.
Ctrl + F11 works wonderfully on Ubuntu / Linux Mint.
following for different plateform
WINDOWS: Ctrl + F12
LINUX: Ctrl + F12
MAC OS X: control + F12 (or fn + control + F12, depending on your keyboard configuration)
for windows try left Ctrl key with F11 or F12 or Num off 7
The complete listing is buried in the android docs, and i only found it via google / dogpile.
http://developer.android.com/tools/help/emulator.html
That link has the emulator shortcut keys as of right now.
=\
To rotate the Android Emulator, just disable the Num Lock key and and use the 7 and the 9 in the num pad to rotate the emulator and change its layout from portrait to landscape.
10 years later, I run into the same problem... For me, the issue is that it was literally disabled in my emulator.
Go to the running emulator, and drag down from the top menu area to make it show the action buttons and notifications. Those action buttons show what features are enabled/disabled, like Wifi, airplane mode, and....rotate.
In my emulator, the 3rd button from the left was the "rotate" button, and it was gray. Once I tapped on it to toggle it on, boom, my app would now switch to landscape mode when I rotated it.
control+fn+F11 will do. There's no need for "command" key
In my windows-8 laptop, ctrl + fn + F11 works.
Ctrl + F12 also works well on linux(ubuntu).
make sure that your hardware keyboard is enable while creating your AVD
-launch the emulator
-install your app
-launch your app
-make sure that your Num lock is on
-Press '7' &'9' from your num pad to change your orientation landscape to portrait & portrait to landscape.
In my case, i succeeded by doing this:
1- enable 'Auto-Rotate', if it isn´t yet.
2- either use rotation left-right option at panel located next to the virtual device, or click (ctrl + left/right arrow key), in order to rotate the device.
Hope it works for you.
On the emulator click down at the top and drag down to bring down the menu. the fourth button from the left (Arrows) is the rotate lock. If it is grey click it and it will turn blue.
Then you can click the rotate phone icon on the right-hand sidebar of the emulator and your screen will rotate.
For those of you with a Chromebook Pixel/Ubuntu/Crouton with no numpad, installing the onboard keyboard worked for me.
Just press 123 to access the numpad layout, and then press 7
If you're on Unity already, onboard may already be installed, so just type onboard from your command line to see if it's there.
If not, just type:
sudo apt-get update
sudo apt-get install onboard
PS: The Chromebook Pixel's upper keys were supposed to represent the traditional F1 through F11 function keys on Ubuntu/Crouton, so you may want to try those special hardware keys first (on their own or in combination with Ctrl). It's just that for me, I'm running an old copy of Crouton, and the only function key that seems to be recognized is F6
If you can not switch to landscape(or portrait) while using ctr+f11/12
Maybe the virtual device (android phone) itself lock the rotation.
Going to the android control center (pull down on the home page), and unlock.
To switch to Landscape mode in android emulator u have 2 ways to accomplish.
1> You can create a relative layout such that when you switch from one mode to other it will change accordingly
2> You can create 2 separate XML file both the views and use it whenever required

Categories

Resources