How can manage layout screen for all android phone? - android

I have two cell phones.When I run same app on both phone is not properly work. For fix that problem i use sw120dip and sw360dip layout. But i cant solve this error.
How can i solve this error.

Use the Relative layout by the way if you are using other layout and design it with the Android Studio Design instead of using xml .In this way you can see the layout of screen without running the app on real phone.

If you use relative layout with all dimensions in "dp" and font sizes in "sp" then it has to fit in all screen size. I have never seen scenario unless one is using fixed layout. Pls paste your layout to get more details about your questions.

Related

Android Preview vs Emulator Layout Size

Folks,
I cant design my android screens and see it on my emulator somehow the resolution, zoom (whatever) in the emulator is big and my layout is messed up.
The whole layout is inside a FrameLayout, the paragraph text in the emulator pic is inside a RelativeLayout, which is set to GONE after users upload rating, then LinearLayout shows up with the overall rating bar in the some place where the RelativeLayout was.
My question is why is this happening since in the preview it seems perfect and on the emulator it seems all messed.
Please see the screenshots:
Android Studio Preview:
Genymotion Emulator
It is really hard to determine what exactly is wrong without seeing your xml markup.
Possible Reasons
You gave your layouts some sort of fixed size, and therefore it appears to be fine on your markup, but whatever you are emulating on Genymotion is using a different ratio.
When you do a View.GONE, you say you are replacing a RelativeLayout with a LinearLayout. Well, do you make sure that the layout that is replaced is layoutAbove whatever that frame layout below it is?
Some layout just has some attribute, like an alignment issue, that is causing this.
Trace your steps backwards, removing one thing at a time. Get it to work with that view gone first, then add it and manipulate it after.

layout on android studio preview doesn't look the same when running the app on the phone

im developing an android app on android studio, when i run my app the layout looks a bit different from the preview as well as on other phones,
for example: the buttons are in different order (from right to left instead from left to right) or other changes similar to this.
as well as on some phones the layout doesn't fit perfectly on the screen for example: the buttons on the sides of the screen appear to be cut out.
how can i fix it so the app will look the same with every phone and not only some of them?
About the Right-to-left/ Left-to-right, you can choose the globe icon in the preview options bar frame and then choose Preview Right-to-Left Layout option. This will "fix" the buttons order in preview.
About the buttons that appear to be cut out - make sure you use dp units instead of pixels. You can read more about it here:
http://developer.android.com/guide/practices/screens_support.html
Make sure you check if you have used the constraints on your components properly. Usually that's what makes the layout messy after running the app on your phone/emulator, even tho it looks perfect on your XML file.

application not fit to the android virtual device

In my android application, I have a problem that when I run my application, its not fit to the emulator and some part cut on it like below:
And also you can see below I have a button also on it like below image:
But its not show me the full image, means a button is missing on the emulator.
How can I resolve it. kindly suggest me, waiting for reply.
Thanks
Basically, your designer and emulator are using different screen dimensions.
You can change the designer to use the same screen dimensions. Currently, from your screen shot you're using the Nexus One layout. From what I can tell the emulator doesn't look like the Nexus One screen dimensions.
With Android it isn't as simple as 1 layout for all dimensions, screen sizes and devices. You have to implement multi-screen support to address this. You can usually do this by having a variance on dimensions, styles and layouts. A lot of the time one layout will work universally, but dimensions often need tweaking.
See http://developer.android.com/guide/practices/screens_support.html for more on Supporting Multiple Screens.
It is a problem that can occur in real devices (remember, we have loads and loads of different screen sizes for android) so you definitely need to fix it.
The best way to avoid this is to wrap the entire layout inside a ScrollView, so the user can scroll to see all the content of your layout.
If you are trying to fit all the elements on the screen then you need to account for different screen sizes and densities. In your particular case you are building the screen on a different sized screen than the emulator.
Assuming you do not want the screen to scroll (which is solved using a ScrollView), then to fix this, you can do the following:
Build different XML layouts for different screen sizes
Use dimen files to specify different sizes for some or all elements on the screen so that they re-size depending on the screen size.
Use weighted LinearLayout so that Android re-sizes the elements according to the screen they are placed on.
Each of these is pretty easy to search and find various ways of doing.

Layout of a android application

I'm working on the layout of an android application. But I have a question about the layout. Once i have created a layout and then go to another screen (for instance 4 inches to 5 inches) all my buttons and text boxes are messed up..
Is there a method to make everything static, so that my layout works on every mobile phone..
What kind of layout are you using, could it be RelativeLayout? that might be your problem in this particular instance.
Anyway, in android there are many screen sizes, each of them you should handle with different layouts depending on orientation, size and density. There is no magic formula as far as I know, but 9-patch images can help a lot. Another thing you should do is make sure that you understand how match_parent and wrap_content values work for height and width.
Check this out: Suppoting different screens
You have to create folders for different types of screens take a look at android developers training
This document contains everything you need.
Instead of having everything fixed, it shows how to design a layer that adapts to the various screens you may encounter.

How to Resize screen of Android

I am developing an application for whole android devices. But resolation of screens are different and that is the biggest problem how it looks. So, I want to make resizing controls and also I used absolutelayout but It is still same.. I give value to controls as dp ..
How can I solve this problem ?
You don't resize the screen of an android device - you make your app instead work with the various screen sizes.
The relevant docs are here.
You cannot hardcode the dimensions of your layout and expect it to work on every screen size. And there is no method which automatically does it unless you write it.
You might want to change your approach, use Relative Layout or Linear Layout instead and use values like fill_parent and wrap_content while designing your layout.
Another approach Android developers follow is use different resource files for different screen sizes and Android loads them automatically at runtime.
Refer to this for more info on how to work with different screen sizes effectively.

Categories

Resources