Different graphical interfaces on the phone and tablet, but in the same application

I need to write an application for a tablet and for phones. Two applications have the same functionality, but they have a completely different GUI.

For example, the phone has 2 buttons on the main screen, but the tablet will have 5, because we would like to use the space that we have. I know, I can define different layouts, it depends on dpi, but how should I handle layouts in Activiies? I think using if (sdkVersion> = 11) bla..bla ... will not work through hole code and hole project! Is this a situation where I have to use support for multiple applications?

articles read: http://developer.android.com/guide/practices/screens_support.html

http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

http://developer.android.com/guide/market/publishing/multiple-apks.html

I do not understand how I should deal with this problem ... please, if you can help, thanks

+4
source share
1 answer

Place the tablet layouts in res/layout-large/ . Put your phone layouts in res/layout/ . Call them the same. Your actions will load the correct ones based on the device on which they work. When you call findViewById() to get additional buttons and see that you are returning null back, ignore them.

You may need additional layouts in places such as res/layout-large-land/ (landscape for tablets), res/layout-xlarge/ (if you want to handle 10+ "tablets differently than material in the range 5-9") , res/layout-small/ (if you want to handle <3 "screens), etc.

+5
source

All Articles