How to fix flex android apps horizontal? - android

I am developing a app running at android pad,I need fix the layout horizontal.
I know that with java,I could set a attribute in a xml file,but I couldn't find a file like this in my flex project.
So how could I fix the app horizontal?

Set the <aspectRatio> to landscape in your application's descriptor file.
You can find that file directly in the src folder under yourAppName-app.xml.
Keep in mind that the current version of Flash Builder has a bug which displays landscape marked apps as portrait in the Flash Builder emulator. If you deploy the application, the correct aspect ratio is set, though.

AndroidManifest.xml -> Tab Application -> Application Nodes -> choose activity and in the field "Screen orientation" choose landscape.

Place layouts for portret mode in /res/layouts/
Place layouts for landspace mode in /res/layout-land
Layouts xml must have same neme, for example mail.xml

Related

Android studio switching layouts when device rotates

I am making my 1st ever android app using android studio,
Everything works correctly except switching between portrait and landscape layouts.
What code do i need to insert and, where to get my app to see the layouts I have made.
Thanks
Michael
You have to create a new folder called layout-land and place it in there.
Ex:
Your layout's current location is layout/my_layout.xml, you would place the corresponding landscape layout in layout-land/my_layout.xml
Check: http://developer.android.com/guide/practices/screens_support.html under "Using configuration qualifiers"
Similar Question:
How do I specify different layouts for portrait and landscape orientations?

How can I specify which layout to use for an Android Wearable?

I have a custom view with an onTouch method that launches another activity with its own xml layout. If I run the program on an emulator that has been scaled to watch size (yes only scaled, normal emulator is fine), it creates an instance of the new activity with both the round and rect layout files. Additionally logcat says eglSurfaceAttrib not implemented.
Because this only happens on scaled emulator, is it just a bug with the emulator? I don't have a real android wear watch yet. Or is there a way to package some attribute with the intent that starts the activity to let it know I want one of the layouts?
Edit: It's having this problem on the emulator regardless of size/shape
The best way to target specific screen sizes or aspect ratios is by using qualifiers for alternate resources.
Based on the developer documentation, using the watch qualifier for your resource will probably do the trick. Your directory hierarchy would look something like this:
src/
res/
layout/
(all of your regular layouts)
layout-watch/
(all of your Android Wearable layouts)

targeting different android devices

I know you can set specific layouts for a device like this:
if(android.os.Build.MODEL.equals("Galaxy S II")){
setContentView(R.layout.resultsGS2);
}
else if(android.os.Build.MODEL.equals("Nexus 7")){
setContentView(R.layout.resultsN7);
}
else{
setContentView(R.layout.results);
}
But what I want is to make a layout for all devices that have similar screen size/dimensions. I have been looking at this: http://developer.android.com/guide/topics/resources/providing-resources.html and I tried renaming the layout folder many different things and whenever I try to edit an xml file in the new layout folder I made and I change the device preview it keeps changing back to the default layout. I am using android studio, and basing the need to make a new layout off of the device previews that it shows. Is there is an easier way to do this besides making a layout for each specific device?
This can be done by having different layout folders and calling them layout- + screen size name and then edit the layouts inside these folders to match the screen size you are targeting.
So for example if you wanted to target something such as the galaxy nexus (320dpi) you would create a folder called layout-xhdpi and all the device specific layouts will be placed in here. And then if you were to run this in an emulator or a physical device you would see the layout that you made specifically for that screen size.

Android - Problems with different sized layouts not working

I have a regular layout file : Res/layout/test.xml
And another layout for tablets : Res/layout-large-land/test.xml
This line is used in my Activity to declare the layout : setContentView(R.layout.test);
I'm using an Eclipse AVD emulator with the customer resolution of 1024x600 (Which according to the android site is a standard 7-inch tablet size). I've declared in my Manifest <supports-screens> with both normal and large as "true".
My problem is that the layout is always the original one, the different, larger layout never gets shown (even though the conditions would suggest it should?). Essentially the difference is the regular layout is a ListView and the large landscape one is a Table.
I've tried finding examples of how to get this online and in text books, but I can't find any that show what else to do. From what I've read, Android should make a conscious decision to pick the layout-large-land file over the regular layout one?
Thanks in advance for your help.
EDIT: I've been playing around with the layout, I've tried layout-land (which works fine), and changed the resolution of the emulator to be 854x480, still with no luck.
A simple solution might work for you:::
change res/layout-large-land to res/layout-xhdpi.

Android - How to stop screen adaptation to rotation

I am a newbie to the android world, and as of today I completed my first application.
I test my work on a physical device, and quite recently it has came to my attention that whenever I turn/rotate my device, my application tries to adapt itself to the new resolution 800x400.
Since I have designed the whole app for 400x800 resolution, this change messes up the original design, as well as sending a new call to "onCreate" method of the last activity it was on, before turning/rotating the device.
I would like to learn whether it is possible or not, or which class I should use to stop the adaption to resolution.
This line (in AndroidManifest.xml) will lock the activity in portrait mode:
<activity android:name="MyActivity"
android:screenOrientation="portrait" />
There are things that you can do to make your layouts work well in different orientations and resolutions, such as using dips instead of pixels to measure your views.
When you have time, consider making layout files for landscape mode. Create a "layout-land" directory within your res directory and drop he landscape layout files there, using the exact same file names for their portrait counterparts.

Categories

Resources