Issues with Android Alternative Layouts in Xamarin Studio - android

I'm nearly flipping out. I'm trying to develop an app for several devices. The app should nearly look the same on all devices. I tried to create the layout like this:
first i created the layout in the standard layout folder for an Samsung Galaxy S Plus device
as that's the only hardware device I have
the layout looks nice on the device
after that I took one layout file and switched through the available virtual devices such as 2.7in QVGA...5.4in FWVGA...7in WSVGA...
everytime when a switched the virtual device and the layout doesn´t look good I set the lock on qualifiers Smallest screen width and Screen size
I make the changes so that the layout looks good for that specific virtual device and saved it.
Xamarin creates an new folder like layout-sw480dp-large. In that folder I can see the recently changed file
I have done this for all layout files in the standard layout folder and for all virtual devices.
back in the standard layout folder I check all layout files with all devices. everything looks great.
I have tested the app on a Samsung Galaxy S3 and the layout looks awful, textviews are not in the right place, image views are not in the right place etc.
so back in Xamarin studio I checked all layout folders and each file. For example, in the folder layout-sw480dp-xlarge the layoutfile doesn't look good.
I changed that file but then something weird happened: all files with the same name lying in a layout folder containing the qualifier xlarge are changed too (see the screenshot).
I thought that changes in a layout folder don't cause changes in other folders. Is this a bug of Xamarin?
So I have 3 questions:
Is this weird behavoir of changing layoutfiles a bug of xamarin?
what is the best way to create layouts for different devices (please practical advises, i know the site of supporting multiple screens)
how can i create layout for Samsung S3 with Xamarin, how can i create a virtual device in xamarin which emulates the Samsung S3
Thank you very much.

i have informed xamarin about this issue. [link] (https://bugzilla.xamarin.com/show_bug.cgi?id=13705).
The way i create layouts for several devices:
Create the layouts for in standard layout folder (i take a normal mdpi device)
when all layouts were created i copy them to another folder outside xamarin and rename .axml to .xml
i use eclipse to create alternative layouts in their specific folders
rename all files inside alternative layout folder from .xml to .axml
in xamarin studio create alternative layout folders and import specific files
run and test them on real hardware devices
this works for me.

If you open axml file in Xamarin Studio, you'll find two options graphical representation/ scrip. You can switch between layouts by changing alternate layouts, switching available near top left corner of axml file.
For custom virtual device creation set same configuration as device which you want and create AVD

Related

Make Android Studio apps available for all devices

I have a question about Android Studio.
If I develop an app that I then upload to the Google Play Store, can I be sure that my Android Studio project runs well and looks good on all devices with an Android operating system?
So that the layout that I developed works well on all screen sizes? Will Android Studio do this for me on its own?
Or do you have to develop your XML layout for each individual smartphone with different screen sizes?
I would be very happy to hear from you.
best regards
However, applications created in android studio will be able to fit all api's that you define in your gradle, it is recommended to test in the emulator from the initial api defined in the gradle, but in general it works well on several devices. The test is ideal to check if there will be no crash in some API's but the layout is usually positioned according to the screen of each device.
Good luck on your project.
So that the layout that I developed works well on all screen sizes
For this, it depends on how you did your layout. Android has constraint layout which is the best to use
ConstraintLayout is a layout on Android that gives you adaptable and flexible ways to create views for your apps. ConstraintLayout , which is now the default layout in Android Studio, gives you many ways to place objects. You can constrain them to their container, to each other or to guidelines.
Or do you have to develop your XML layout for each individual smartphone with different screen sizes
For this, it will only base on your use case or if you have different UI design for phone and tablet devices, for example, you want your app to show a two-pane layout on a larger screen (or a tablet), then you have to create a new xml for this. So you'll have mylayout.xml placed in layout folder (for phone device screen sizes) and mylaout.xml placed on layout-600sd600dp (for tablet device screen sizes).
But if you only have on design for both phone and tablet devices, then you only need one xml layout.

Android layout folder name for Nexus 5 mobile

I want to design an android layout for nexus 5 mobile and need to give a fixed width/height. After searching with many websites I have used the layout folder named as "layout-normal-xxhdi". It works perfectly for nexus 5 but unfortunately it will affect other mobiles. Ex) I tried with moto e it also takes the layout file from "res/layout-normal-xxhdpi.xml" folder. Please someone give the exact layout folder name for nexus5.
My layout folders,
res/layout.xml
res/layout-normal-xxhdpi.xml
Note:
For other mobiles it will need to take the layout file from "res/layout.xml"
You cannot do this with folder name. But you could try to recognize the device model (here Nexus 5) in your Java code and use the appropriate layout. To do that, you could use Build.MODEL.
Testing in AS v1.5 using the default Nexus 5 emulator (selected replicate device during creation), you can almost specifically target Nexus 5's specs using the "sw384dp-xxhdpi" folder name.

Tool for quickly testing Android layouts

Android layouts are very tricky to get right. Especially for an inexperienced layouter like me. At the moment I use the following workflow:
Design the layout in IntelliJ, using IntelliJ's GUI preview window
Test the layout on my device
Test the layout on different emulator images
This approach has several problems:
The IntelliJ is very inaccurate (often the layout looks very different on the device)
Testing on my device is good, but here I have only one fixed resolution and PPI
The emulator takes AGES to start up. If using multiple emulators things get worse
That's why I'm looking for an alternate solution: a tool, that quickly renders Android layouts (no app logic required). This tool should support different resolution and PPI settings and should be as close to the actual looks on real devices as possible.
Is there such a tool?
What other alternatives are there?

How to load right layout in emulator?

I have two folder res/layout and res/layout-sw600dp. When I try to run my app in Tablet Emulator 7 inch (1024x600) I see on screen layout from res/layout. How to see another layout for tablet from layout-sw600dp in Emulator?
Double click the layout you want to open or choose a different setting from the drop down menus and the relevant layout will be loaded. e.g Nexus One, Nexus S etc
Add a custom layout in this menu if the defaults do not suit your devices.
To see these layouts at runtime you need to run your app on a device\emulator that matches the layout settings.
To be able to see both layouts, you will need to use different Android Virtual Devices (AVD's), or in other words, a different Emulator. The android documentation has a page dedicated to managing AVD's.
The android development team has provided a tool that you use to create AVD's called AVD Manager. I believe that you have used it, because to be on an emulator means that you have already created one!
You can find it in Eclipse in the following location:
Window -> AVD Manager
To actually see the different layouts between the different emulators, you will need to configure them differently, to accurately represent the device you want to target. You should be able to tweak the Hardware options to make your emulators behave differently. You can find a list of hardware options here.

Android phone and Tablet problem

I know this is not a technical related question.But i do not have any idea.I am going to develop a project which should be supported in both phone and tablet.Is it possible having one project working for both tablet and phone ?
Yes. The only thing you need to keep in mind where you keep your graphics. Because it will cause different problems if you do not treat and handle them depending on the screen size. Only thing matters is the android version. If you deploy your app in any phone or a tablet where the version is newer or equal to the target version it works. But of course you cant take a call or some other mobile functionality from a tablet if its not supporting that features.
You can use drawable-hdpi,drawable-mdpi and drawable-ldpi for the graphics(images which use in project) and also use layout with multiple screen by custom layout like layout-480x320 , layout-600x1024 etc. in layout you can custom screen xml file.

Categories

Resources