android app for tablet of multiple resolutions - android

How to make an android applications for tablet of multiple resolutions like 1024x600pixels or 1280x800 pixels. I had made an app for the resolution 1024x600 but it completely get distorted on the the tablet of resolution 1280x800...
Any Help....
Thanks in advance....

Step #1: Replace your "handling the whole layout programmatically for all the activities" with XML layout resources. IMHO, while it is possible to define your UIs totally in Java and handle multiple screen sizes, that is a technique reserved for expert Android developers. In other words, if you have to ask "how to make an android applications for tablet of multiple resolutions", then you lack the experience necessary to be "handling the whole layout programmatically for all the activities".
Step #2: Follow the guidance of the Android developer documentation for supporting multiple screen sizes.
Step #3: If you still have problems, ask more specific, focused, and longer questions. In other words, explain specifically what your problem is, supply the code/layout XML that is giving you problems, and supply screenshots to illustrate the output you are getting.

Related

Implementing Layouts According to Screen Size

I'm wondering if it's possible to use different layouts based on a phone's screen size (not tablets, watches, etc.). I've already taken a look at this article, but don't seem to be having any success implementing what it suggests. Just for context, I'm using a ConstraintLayout for all of my layouts. I originally designed my UI using a Pixel 3 XL, and when I try to run my application on any other device, the UI looks distorted, its elements aren't anywhere they should be, and everything is just awful.
How would I go about making and assigning layouts for each screen size? Is there something else I could do instead?
Google recommend to create different res/layout directory for specific pixels, such as res/layout-1024x720,res/layout-1280x720,res/layout-1920x1080 etc..
#Inso is right, you can just save different versions of your resourses in different versions of your res/ subfolders (like layout-1280x720 or drawable-1920x1080). This not only applies to layout files but also to drawables and any other resource directory and you can create different versions not only by screen resolution but also by device API screen size and others.
I recommend you read the following documentation that explains all that is possible.
It might also be that you just chose the wrong layout type for your app. you should check the available documentation on layout types (there is a bunch out there) and see if maybe ConstraintLayout may have been the wrong pick.
I also recommend having a set of different virtual devices (from the emulator) having different screen sizes and running different APIs so you can test every now and them how your app performs under differnet conditions

Android User Interface Scaling

I have a project I am working on where the UI I have developed looks great on a 7" tablet, but the moment I try to use the app on a 10" tablet there is a lot of extra space to the right and bottom of my UI elements. Is there a way to scale UI elements to be bigger based on the size of the screen?
I need the UI to look exactly the same on every resolution possible. It should be noted that I am restricted to Eclipse and am programming on an older version of Android because the utilities I have been supplied with are older utilities.
Wish I could supply a screenshot, but I 100% cannot.
You can use different layouts for different screen sizes.
layout-sw600dp ( for 7 inch tablets)
layout-sw720dp ( for 10 inch tablets)
The system will automatically pick the layout per current device size. Just make sure to have the same layout name and id of the components in the layouts or it might cause exceptions if mismatch is found.
If you want completely different layouts for different sizes ( file names still have to be the same ), you can determine which kind of device it is, you can follow the description in the following's accepted answer.
Determine if the device is a smartphone or tablet?
Now using the above method, you can find appropriate views using IDs or whatever way you prefer without causing exception. I personally just change the dimensions of things and keep the ids same.

Supporting different devices with different layout

I have doubt in making the layout for other deices I mean to support different devices of different resolutions. I have made an application and it is working well on hdpi devices and I tested on Samsung Galaxy grand which has 320dp-460dp and 480px-800px.
May application is looking awesome on this device. but when I run on other devices its gone bad. SO I am suggested to make the folder like layout-large, layout-xlarge and layout-xxlarge but there is a lot of difference in this link and this link
So this makes me confuse , with which name I have to make the layout folders to support all devices ?? please tell me
and also tell me I have some hard coded values in my layout such as left margin 13 dp to make my design look perfect on hdpi device should I make it more in other xhdpi devices ???
and also which devices comes in layout-large folder and so on please answer my both confusion , thanks in advance
I use Google's code as an example of how to do stuff. The docs on "Supporting multiple screen" is a bit old and outdated. The best way to keep up with the current conventions is to follow other's codes.
Here is the source code for the Calendar app. Yes, there a lot of different folders for layouts/drawable/values but you have to consider the fact that there are a lot of devices with varying sizes and pixel densities.
Also, why do you want to make many folders for layout? You make a few layouts and let the values and drawables do the rest of the work. Hope it's helpful.
IF you are interested in knowing which device falls under which folder, then check this figure from the Official Android Guide:
Of course you need to know the actual size or density of the physical device

Universal Android application for tablet and mobile

I want to develop an application which is universal for tablet as well as for mobile. By creating xmls of different screen sizes i.e. small, normal, large, and extra large, does my purpose will be solved?
I am not sure about this, please guide me to develop that application in every aspect.
Thanks in Advance.
You should take a look at the designing for multiple screen sizes documentation.
Beyond that, you may not need layouts for each and every size. Sometimes, scaling a smaller/bigger layout up or down will suffice.
You will also be need to make sure you don't end up using features like cell phone calling, as most tablets don't support that.

Easily scale android application for smaller screen sizes

Right now I have an application I built that is built for android 10.1 inch screens (tablet) and I would like to to be able to be scaled so that it work on the kindle fire (7 inch screen). What would the easiest way to do this be?
Edit:
So I've taken the advise that the majority of the people in this tread have given and replaced all of the absolute layouts with relative layouts and I am using margins left,right,top,bottom, to place them, but still the button images are too large and they are misplaced, how can i do this so it works correctly?
There are some design criterias for developing android applications to make them work in different configurations like screen size:
use different layouts for different configurations
use fill_parent and wrap content properties in layouts
do not give hard coded pixel values
do not use absolute layout
provide different drawables for different configurations
for more look here: http://developer.android.com/guide/practices/screens_support.html
Following the best practices guidelines is always good but sometimes you simple need a whole new layout for different screen sizes. Android allows you to create different layouts files for different screen sizes. To do this you can create a new folder under 'res' called 'layout-large' or 'layout-large-land' for landscape. The same is also true for 'layout-xlarge' and 'layout-xlarge-land'. You can just add another xml layout file in these directories with the same names and same ids and android will automatically pick the right one based on the users screen.
http://developer.android.com/guide/practices/screens_support.html
Honestly, it depends on your application. If you built it so that it would work with tablets and you didn't specify non-percentages for your widths and heights, it will probably automatically scale to the proper size on the Kindle Fire.
Honestly, get a test device (or emulate the size using the Android Emulator) and see what happens. Very likely, if you followed proper design patterns, the app will Just Work (TM) on the Kindle Fire.
If it doesn't, you might want to take a look at how you're specifying the sizes of your elements. Using Pixels or any other type of pixel-based numeric measurement will do some strange things to your UI. Instead of widths and heights, use paddings and margins defined with density independent pixels. This will help your app scale properly.
I recently wrote an app testing it only on mobile phones, and was pleasantly surprised when I purchased a tablet, and the app scaled up perfectly - with no warning from Android about different ways to scale it.
Realy easy, but not recommend because it can pixialize images, is Enabling Screen Compatibility Mode.
Try adding this:
<supports-screens android:compatibleWidthLimitDp="320" />
OR this:
<supports-screens android:largestWidthLimitDp="320" />
to your AndroidManifest.xml.
To understand whats happening check here:
http://developer.android.com/guide/practices/screen-compat-mode.html#Enable

Categories

Resources