Screen Compatibility - android

I have developed an Application for android compatible devices mostly covered mobile phones, but when I am running it on Tab the screen size will get changed and all the content on the particular screen not behaving properly, As I have designed it keeping in mind that it should be compatible with mobile phones
Now, I just wanted to run my app on tab with the same screen size as it is showing on my mobile phone, without stretching of screen size.
What should I do to achieve it ??
Thanks

This isn't really a question that can be answered with a simple "set this style flag on your activity and you'll be on your way!" kind of answer. To get an app to scale properly across multiple screen sizes, you really need to start with the layout design itself. Android will try to keep your components the same size across different screen densities, but if you just leave it at that it still won't look very good because you'll have lots of empty or poorly utilized space.
The platform documentation and design guidelines go fairly in-depth into screen size compatibility and making a single app work and look good across all screens, large and small. In particular, I recommend reading the following articles:
Supporting Multiple Screens
Supporting Different Screen Sizes
Supporting Different Screen Densities
It'll take some work to make your app look and work great on tablets and phones (with just one APK) but if you want to make a good experience on a tablet without the hassle of maintaining two separate codebases, it's worth learning.
Pay particular attention to size qualifiers, which allow you to load different resources (drawables, layouts, etc) based on screen size (small, medium, large, x-large). That way you don't have to just blindly scale everything up on a tablet... if appropriate, you can tweak your layout on a tablet to make the experience more user-friendly.
Additionally, I recommend looking into Fragments, which allow for lots of flexibility in your UI across tablets and phones while not requiring you to have to write a bunch of code for differing layouts. For example, instead of having a newsreader that has two screens, one to display a list of articles and one to display article content, you can use Fragments to have a side-by-side, two-pane view of articles and content on tablets, while still having two separate screens on phones, which are more narrow. Fragments and FragmentActivities make this much easier to write and maintain.

You could set layouts width and height in pixels.
It probably isn't the only way but it's what comes to my mind right now.

Related

Android Manage view sizes on different screens

I want to make my view Responsive, look at following images.
1st Image is what it should ideally look.
But when I change the screen size, it changes the size and alignment. I want fixed size views over all screens.
You should follow Step by Step approach .
Android runs on a variety of devices that offer different screen sizes
and densities. For applications, the Android system provides a
consistent development environment across devices and handles most of
the work to adjust each application's user interface to the screen on
which it is displayed.
Read Supporting Multiple Screens .
To optimize your user experience on different screen sizes, you should
create a unique layout XML file for each screen size you want to
support.
Read official guideline about Supporting Different Screens .
Read Build a Responsive UI .

What do I have to worry about when making a mobile game for different phones?

I want to get into mobile game development but before I get started I want an idea of what the process is like so I can choose the right tools.
Obviously screen resolution is the most obvious, but what other things have to be changed so it will work on multiple phones?
This is an enormous topic. The most basic design is to have a rectangular play area that can be stretched to fit the screen you are using. Whether you keep your original aspect ratio or "match_parent" for both dimensions is up to you.
You've recognized that that won't take full advantage of screens of different resolutions so many courses and tutorials will walk you through learning to design a relative layout that will arrange and size some elements according to the available space and other elements according to how much space the content needs. You'll also eventually provide images of different resolutions that will be used for different screen densities.
I recommend you jump right into game development before understanding this topic fully. There are many intricacies that you'll come to understand as you work with them.

stabilize android layout design for tablet and mobile

Actually I need some suggestion like Designing screens for android mobile as well as tablet. As of now im creating two different folder for xml one is for mobile and another one is for tablet. Im placing images in 4 different images with 4 different resolution like (160 dpi, 240 dpi, etc). so am i going in right way or i need to change the way of designing. Thanks.
When designing for different devices it is important to test whether there is a necessity to create different layout files for the different devices. If you find that you do want that then there is plenty documentation online about it. Read these first:
Designing for different screen sizes
Guide lines
More android screen size documentation
Each of these links explain the new methodology of designing for multiple screen sizes.
A few tips on top of the already answered question that I gained by experience:
Use #dimen everywhere you have to specify a width/height but in general, avoid specifying them if you can. This way, you can override the dimension based on the available DPI and don't have to replicate your layouts.
Use LinearLayout wherever you can and use weights to determine how things should be drawn. Other layouts like relative layout are fine as long as they're used for positioning (isLeftOf for instance) as opposed to making a certain space available.
Use fragments wherever you can. It's much easier to work with self contained fragments. In general, avoid having any UI logic in your activities and let the fragments handle them.
Use the Android Asset Studio (http://romannurik.github.io/AndroidAssetStudio/icons-actionbar.html#source.space.trim=1&source.space.pad=0&name=ic_action_example&theme=light&color=33b5e5%2C60) which will take care of resizing your images for you. It's been very valuable to me. Have a look at these other projects too. They can help you in many aspects when designing your UI: http://romannurik.github.io/AndroidAssetStudio/
Even when you do all this, you may come across a scenario where you really do need to write a different layout for tablet and phone. If this is the case, as long as you've created everything in self contained fragments, it's much easier to switch fragments or even use the same fragment code with different layouts (as long as they contain the same UI elements) depending on the dimension. It would also be advisable to use the trick here (Determine if the device is a smartphone or tablet?) to determine if you're running on a large/small tablet or a large/small phone.
All in all, it's a little bit painful developing and testing your app on all the available device sizes but as long as you follow the above points, you'll have an easier time.

Android App XML multiple screen support

I made a calculator app and used density independent pixels to create the layout, place the buttons and so on. Yet on a tablet emulator it doesnt display correctly, it only takes about 1/4 of the screen. On my phone(800x480) everything is ok. How can I adress this issue?
You'll need to provide additional layout folders for the different screen sizes so that the Android system doesn't use the same one by default, resulting in the behavior you've described.
This is accomplished by adding layout folders with size specifiers such as: small, medium, large and xlarge.
layout-small is an example.
So, to be clear, you're adding additional folders for the different supported screen sizes. You'll then add a layout of the same name to each folder you add. The system handles the headache.
You would then alter the layout to achieve the best results. Note that it is common practice, when dealing with larger screen sizes, to provide more content on a single screen as opposed to blowing everything up. If your app can benefit from that, it looks better than having obscenely large buttons stringing across the screen, IMHO.
For a complete run down, please refer to Android Documentation.

simply scale up phone xml layout for tablets

I designed my app for phone. If all I want for it on Tablet is just to scale up everything (i.e. bigger images, more distances), Is there a way to ensure this happen when doing my XML (or in the code)? Or should I create a different xml for xlarge screens?
I always come across the question and don't know the answer. Please don't refer me to the documentation of supporting multiple screens because I read it many time and it shows how you can customize for diff screen sized. In my case, I just simply everything scaled up keeping the same ration as the phone
Thank you

Categories

Resources