My android app looks different on the phone than android studio
look at screenshot
app in the phone screenshot
App in the Android studio screenshot
why is that? and how can I fix that?
Your preview shows what your layout would look like on a Pixel 3, which is quite a large phone. From what I saw on your screenshot looks like your device isn't quite as large so I'd recommend you to use ConstraintLayout for 2 reasons:
Consistency across different screen sizes - it's much more likely your layout will look the same on a large screen and a small one
Better performance, especially for your case since you'll be able to do everything with a single layout, without having to nest several layouts
For more information on ConstraintLayout, please check out this post I wrote on Medium
Related
The screens in my app needs to be displayed in the same way on both type of devices, phones and tablets. Currently my app works fine on phones, but they behave weird when run on tablets. The problem occurs with the positioning and size of components in the screen.I have 9 patch images generated for all the images being used but still for some components that I use absolute size/margin values such as 30dp,50dp etc do not seem to be good measures that work well on a tablet. Some of my thoughts/questions are:
PercentRelativeLayout - is it the best solution to overcome this
problem?
Is there a way that layouts can be defined so as to draw
differently on phones and tablets. Please note that that I do not
have any complex menus or behaviour that needs to work differently
on different devices, they are same.
Do I have to develop 2 different apps?
you have to make different layouts for both android phone and tablet.
Look at this link
Read more on the Android developer documentation after reading answers above. Found this resource to be more explicit for someone who is totally unaware of supporting multiple screens. http://www.survivingwithandroid.com/2012/07/how-to-support-multiple-screen-in.html
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?
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.
reading about all these different resolutions and hardwares for Android I am a little unsure if the layout I created for an Samsung Galaxy will actually work the same way on all (most) Android devices.
I did not use anything fancy or complicated. However I had to use fixed width in several places to align text and buttons nicely. ALso there is some text with linebreaks that could look differntly if on narrower screens
How can I be sure that my layout will work on other devices? Or is this actually a no issue? Testing in the debugger is sooooo slow, that I actually never got it to work properly.
Thanks very much!
You can set up multiple emulators with different screen sizes, that simulate the possible targets.
In the emulator Ctrl-F11/12 (thanks #ccheneson) allows you to change the orientation, so that you can test that as well.
The emulator may be slow, but to see how the layouts look like it should be fast enough - you may still test the logic on a real device.
Also emulator speed seems to be highly dependent on the screen size.
Is there a truefire way to make sure my app will display the same on my Motorola Droid 2 as it will on other Androids?
I use nothing more than basic Linear Layouts, Image Views, Buttons etc - is there a good checklist to go by before I even think about launching an app?
Clipping issues, What SDK I should launch my app in, etc...?
Make sure you are following the guidelines for supporting multiple screen sizes.
You can use the emulator to experiment with the different possible screen sizes and densities, as described in that document under how to test your app.
You can make emulator of different screen sizes to check your application.
One thing make sure you don't use "px"(pixels) anywhere in your application, use dp instead of px.