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
Related
I'm developing an Android app... when I run it on my Motorola it runs ok, but when I launch it in my Samsung device, that has less screen size, the app doesn't show some buttons. It seems that the resolution is different in either both devices.
How can I configure my app so I don't have problems running in mostly devices?
As stated #abed in his answer, ConstraintLayout should be good for solving most of this issues, but you can never know that it will be fine on all devices.
Testing on multiple devices is one way to be sure, so if you expect that there will be problems, or that something should be different. You can easy see behavior on multiple devices inside android studio like this:
So just change phones with different resolution and observe behavior. If you want different behavior create new layout for that resolution.
when you build your layout Use <androidx.constraintlayout.widget.ConstraintLayout
check this https://developer.android.com/training/constraint-layout
i am developing an application for android 4.0. that app in emulator is looking in good size but when we check that application in real device, all images in apps are being very small in size. what should i do? please help me.
If I am following you correctly you are under the illusion that the emulator will mimic a device exactly? And that because your design looks good on the emulator it will translate exactly over to the device?
If that assumption is correct then you need to be aware that the emulator is never going to give you that kind of accuracy. From my own experience the emulator will help as a guide but it cannot and should not really be used as a like for like match against a set or specific device. This all comes down to the fact that different phone manufacturers use different chipsets and render their screens differently to each other. The best thing you can do is to effectively follow the guidelines here http://developer.android.com/guide/practices/screens_support.html to provide a layout that closely resembles what you want.
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.