简体   繁体   中英

android application layout for android phones and tablets

I am writing an application that needs to be supported on both android phones and tablets. I want to create a tablet-friendly UI for this application. As such, I want the app to be user-friendly both on small and large screens. As specified here: Supporting Multiple Screens , I can create different layout files for different screen resolutions, as well as different drawables for different densities, which is very good.

On top of that, I'd like to use the features of android 3+, like fragments, which are ideal for large screens. A layout which fits a small screen nicely will, in many cases, look poorly on tablets, so fragments would come in handy. However, if I use fragments and target my app for Android 2.2, it won't compile.

So what are the options for this? Should I create a completely different Tablet version of the app? Is there another better way?

You can get the Fragment API working across the whole Android platform using the Android Compatibility Library .

If you're using Eclipse as your IDE, just Right Click your project and select :

Android Tools -> Add Compatibility Library ...

So to answer you question: The best way to make an application Tablet and Phone friendly is to use Fragment in order to design your UI.

Hope this helps!

You'll need to use the Android Compatibility Package (http://developer.android.com/sdk/compatibility-library.html) in order to do this.

It will backport the fragment features back to 1.6 or something.

you can use the support library and compile for both 3.0+ and 2.3. If in the xml you use features that are not supported by the support library you need to store them in a folder with name like xml-13. You need to set the target platform as 13 and the min as 10 for example. If when yu debug on 2.3 you see a red cross don't worry run the application anyway it will work

Have a look to:

similar question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM