I developed an app for handsets, and now I want to add support for tablets. But in my app the UI for mobiles and tablets will be entirely different, and it seems like I need to use different activities for phones and tablets, and I want to use fragments for tablet but I don't need fragment kinda UI for phones. Is it possible to use normal activity for mobiles and fragment for tablets? Where to specify resources for tablets?
-
did u ever visit the android [developers](http://developer.android.com/guide/practices/screens_support.html) website? – Neoh May 09 '13 at 06:14
-
There r many questions about this matter in SO and even in developers website also there is clear information about how u could achieve this... have a look at them – Braj May 09 '13 at 06:56
2 Answers
Its better to use fragments in case of tablets.
Check the Basic Guidelines in the below link
http://developer.android.com/guide/practices/tablets-and-handsets.html
For supporting multiple screen provide different drawables and layout
http://developer.android.com/guide/practices/screens_support.html
You will have to mention support screens in your manifest file
<supports-screens android:resizeable=["true"| "false"]
android:largeScreens="true"
android:xlargeScreens="true"/>
You will have to have different layout xml files
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
For drawables
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
Starting with android 3.2
res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
Note: I suggest you check the video in the link http://www.youtube.com/watch?v=amZM8oZBgfk
You can download samples form the developer site

- 132,755
- 26
- 225
- 256
See Supporting Tablets and Handsets
Here are a few guidelines that will help you create an app that provides an optimized user experience on both tablets and handsets:
Build your activity designs based on fragments that you can reuse in different combinations—in multi-pane layouts on tablets and single-pane layouts on handsets. A Fragment represents a behavior or a portion of user interface in an activity. You can think of a fragment as a modular section of an activity (a "fragment" of an activity), which has its own lifecycle and which you can add or remove while the activity is running. If you haven't used fragments yet, start by reading the Fragments developer guide.
Use the action bar, but follow best practices and ensure your design is flexible enough for the system to adjust the action bar layout based on the screen size. The ActionBar is a UI component for activities that replaces the traditional title bar at the top of the screen. By default, the action bar includes the application logo on the left side, followed by the activity title, and access to items from the options menu on the right side. You can enable items from the options menu to appear directly in the action bar as "action items". You can also add navigation features to the action bar, such as tabs or a drop-down list, and use the application icon to supplement the system's Back button behavior with the option to navigate to your application's "home" activity or "up" the application's structural hierarchy. This guide provides some tips for using the action bar in ways that support both tablets and handsets. For a detailed discussion of the action bar APIs, read the Action Bar developer guide.
Implement flexible layouts, as discussed in the Best Practices for supporting multiple screens and the blog post, Thinking Like a Web Designer. A flexible layout design allows your application to adapt to variations in screen sizes. Not all tablets are the same size, nor are all handsets the same size. While you might provide different fragment combinations for "tablets" and "handsets", it's still necessary that each design be flexible to resize to variations in size and aspect ratio.

- 9,035
- 2
- 28
- 42