Android: how to the design app for Smartphone AND Tablet?

元气小坏坏 提交于 2019-12-23 01:05:06

问题


I know there are already quite a lot of blog entries, how to's, questions out there that cover backward compatibility of Android 3.0 apps.

However, after reading them all I'm just more confused than before. :(

What I have is a Smartphone app that supports min. SDK version 8 (2.2).

I now want this one to stay the same on Smartphones, but also provide a fancy version on Honeycomb Tablets with Action Bar and Fragments and so on.

I know there is the compatibility pack, but all I read about it was about Fragments. What's with the Action Bar and the holographic Theme? I did get this pretty nice and easy just by changing the targetSdkVersion to "11" on my Tablet. How could I reach this with the compatibility pack?

Or would you say it's better to develop two different versions of the program? (And maybe merge them together later?)

Kind regards, jellyfish


回答1:


Keep one apk and just use alternative resources for your Tablet.

Take a look at:

http://code.google.com/p/iosched/source/browse/#hg%2Fandroid%2Fres

This show's you the directory structure of how to target SmartPhones and Tablets (with honeycomb) in the same APK.

EDIT

fancy version on Honeycomb

using Fragments won't change your UI in honeycomb it's just a way to re-use code. So you don't need Fragments to make your UI 'fancy'

EDIT 2

To find the current running Android version you can do something like

int b = Integer.parseInt(Build.VERSION.SDK);              
if(b >= Build.VERSION_CODES.HONEYCOMB){
      Log.i(TAG, "Found A Tablet Running Honeycomb or newer");                  
 }

EDIT 3

in your Activity call getActionBar(); you then have access to all action bar methods stated here: http://developer.android.com/reference/android/app/ActionBar.html




回答2:


There was a talk on this very subject at Google IO this year. Now available on YouTube http://www.youtube.com/watch?v=WGIU2JX1U5Y&feature=youtube_gdata_player



来源:https://stackoverflow.com/questions/6151725/android-how-to-the-design-app-for-smartphone-and-tablet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!