Creating Android Application for tablet - android

I already have the source code for a mobile application in Android. Using that source code I want to create a tablet version for the same application. What are the steps that I can follow and what aspects should I keep in mind while making the UI for the tablet version?
Note : I have never made a tablet application before.

To create app for all size you need should follow below point. It will help.
You need to create set you layout for all layout.
Ignore static value in your xml like margin, padding etc.
if its necessary then use dimen.xml in your value folder.
Please refer below link of android:
http://developer.android.com/guide/practices/screens_support.html
If necessary then use image (png).
Try to use css(create xml) for selector and background. its auto manage for all layout.
Try to use 9 patch images.
Give support for all screen in manifest file
< supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
Android supporting multiple resolution with multiple layout folder
Tutorial:
http://wptrafficanalyzer.in/blog/different-layouts-for-different-screen-sizes-in-android/

Related

Android single screen layout for all devices

I created an Android app and tested it on Nexus6 Emulator. Everything seems fine on Nexus6 Emulator but when I ran that app on real devices (Samsung S6 and S5) the layout was all messed up. How can I fix this?
Do I have to create separate layout for each device?
Does Android have something like 1 layout for all screens?
I dragged and dropped all images in drawable folder instead of using "add image asset". There is nothing in hdpi, mdpi folder. All images are in drawable folder. Is this the cause of my issues?
Please advise.
It is all about the design of your xml. When designing your pages, try to use 'match parent' and ensure that you are making a layout that fits across all screen resolution. Look into AFAIK...
https://developer.android.com/training/multiscreen/screensizes.html
https://developer.android.com/training/multiscreen/screendensities.html
https://developer.android.com/guide/practices/screens_support.html
How to define dimens.xml for every different screen size in android?
For example:
In your xml
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />

Android layout qualifier does't work

Problem:When I tested my program on different size Android phones, the layout were not selected correctly.
I used setContentView(R.layout.activity_home) to set the layout.
In the res/ directory, I created
res/layout/activity_home.xml
res/layout-sw320dp/activity_home.xml
res/layout-sw480dp/activity_home.xml
res/layout-sw720dp/activity_home.xml
In the AndroidManifest.xml
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:anyDensity="true"
/>
Then I tested it seperately on 320x480,480x800,720x1280 emulators. All these devices selected the layout /res/layout-sw320dp/activity_home.xml.
The target platform I set is 4.4.2 and the emulator's version is 4.3.3.
I have no idea why this happened..
http://developer.android.com/guide/practices/screens_support.html
and
/ here
here
use this link and use the directory structure to support multiple screens
Hope it may help u

Android application for Tablet

I have developed an application that is to be run on android Tablet as well. It is working on android phones perfectly. When I ran it on Tablet, it did not expand on whole screen. It just covered a area equal to a mobile device. I want that it also runs on Tablet and cover the whole screen as running on mobile device. Do I have to create two different designs for each type and at run time before using design, I would have to check it whether it is android phone or table?
Add below code in android manifest
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
Add the following block of code in your manifest file after the <uses-sdk>tag:
<supports-screens
android:xlargeScreens="true"
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
Note: Add the android:xlargeScreens="true" attribute if and only if your minSdkVersion is equal to or more than 9.
In addition to adding this block of code, follow this link. Also suggest you to go through the following links:
Supporting Multiple Screens
Supporting Different Screen Sizes
Supporting Different Densities
Hope this helps.
please try
<uses-sdk android:minSdkVersion="8" android:maxSdkVersion="11"/>
<supports-screens android:anyDensity="true" />
in Manifest.xml before tag.
I hope it may be help you.
Yes, ideally you'll design layouts targeted to tablets. You don't have to, but you can. See here for details. Your app is running in "screen compatibility mode". See here for info about that.
I think you used fixed width and height for any view or layout in your app, to support a fixed resolution of your mobile device.
If you use fill_parent, wrap_content and weight property, such things in your app, the app will fill entire screen of any android device. Once review your code.
Small example
Assume device has no rotation. Your device has resolution 320 X 240. you have to fill 3 buttons horizontally, you can put each button width=100 and remaining as margin/padding of layout. If you run same app on device with resolution 640 X 480, some space will come after 3 buttons. If you use width=fill_parent and layout_weight=1 for these 3 buttons and parent's layout_width=fill_parent, on any resolution these 3 buttons will fill the entire width of screen.
I hope it may help you.

Android Application not fit to screen correctly

I have found a problem in Android Emulator,
when i run application on Emulator on android 2.3.3 WQVGA400 it runs fine,
but screen width size is so small
so i check the Built in Resolution to make width size to 800" something and height t0 600"
Now my problem is when i run application on this, then it shows only in a short portion of Emulator screen, extra space on below is always remain
And one thing is that when I run on Actual device is runs very perfectly
You should probably read this: http://developer.android.com/guide/practices/screens_support.html
Add to your AndroidManifest.xml
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
How do you add the text in the green buttons? Is this button a nine patch image? Is the text separate from the image?
Use nine patch images. Then add the text using Button control, where you put the image as background and the text as caption/title/text so on. And when you run the application on larger screen, the image + text will be resized correctly.
Add next line to your AndroidManifest.xml:
<supports-screens android:resizeable="true" />
More information about this attribute can be found in documentation.

Android- Providing Alternative Resources not working?

I feel as if I'm missing something.
In my application, I decided to provide alternative drawable resources and alternative layout files. My structure is as follows:
res/drawable-hdpi/filename.png
res/drawable-mdpi/filename.png
res/drawable-ldpi/filename.png
res/layout-small/layout.xml
res/layout-large/layout.xml
res/layout/layout.xml
I created three different emulators: one with the default HVGA, one with QVGA, and one with WVGA800
It doesn't seem to pick up those alternative resources/layouts based on screen size/density, or maybe i just can't tell?
Is there some way, other than using a device for each specific size, to test this? Or am I just missing something important?
Another question, how well does Android scale drawables if no alternative resource exist?
A few points, in no particular order:
Layouts are related to screen size and thus to large, medium, small and drawables are related to density and thus to hdpi,mdpi,ldpi. It is obvious to some and not so easy to understand to others.
Read through this and create your emulator devices as specified in this page, double check to ensure you got them right.
Now start with just a simple layout and test it on the default device skin, then add layout-320x480, test, repeat for other sizes. If you are using layout-large/small etc, remember to add the correct lines to AndroidManifest.xml <supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizable="true"
android:anyDensity="true" />
One simple way to do this is to have a default layout.xml and drawables folder, and for different sizes have layout-320x480.xml etc folders and different densities we have drawables-hdpi etc folders. If you make sure to set android:anyDensity="false" /> in manifest file then the handset will get correct layouts and assets depending on its attributes.
If you set android:anyDensity="false" /> in manifest file the handset handles the sizing of drawables, typically taking assets from drawables folder and resizing it.
In 3.2 above version android developer have been released two new things for tablets
layout-sw600dp-land
layout-sw720-land

Categories

Resources