Android 4.0 UI for Tablet and Handset
2012-02-29 10:36
555 查看
Android 4.0(ICS) merge handset and tablet UI together, make customer flexible to use which UI they want. On marketing nowdays, phone use phone mode directly and other product like tablet/MID/PND use tablet mode.
ICS support multi-panel in tablet mode to fully use advantage of large screen size which is the major difference with former Android version.
Following layout gives us a brief knowledge about ICS UI:
+-------------------------------------------------+
| System bar (only in phone UI) |
+-------------------------------------------------+
| (Layout with background drawable) |
| +---------------------------------------------+ |
| |
Title/Action? bar (optional) |
| +---------------------------------------------+ |
| | Content, vertical extending |
| | |
| +---------------------------------------------+ |
+-------------------------------------------------+
| System bar (only in tablet UI) |
+-------------------------------------------------+
config_statusBarComponent choose which resource we want, statusBar or systemBar.if phone, use com.android.systemui.statusbar.phone.PhoneStatusBar?; while
tablet, use com.android.systemui.statusbar.tablet.TabletStatusBar?. frameworks/base/packages/SystemUI/src/com/android/systemui/SystemUIService.java
res/values/config.xml
canStatusBarHide defined inframeworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
mStatusBarCanHide true or false determine status bar or system bar.
Here if shortSizeDp smaller than 600, then system use as tablet mode, otherwise phone mode. DENSITY_DEFAULT is fixed 160. Therefore, 800*480 resolution which compute as 480*160/DENSITY_DEVICE and 800*600 compute as 600*160/DENSITY_DEVICE. So 120 should be
suitable value to make both needs the tablet condition.
frameworks/base/core/java/android/content/res/Configuration.java system configuration
ICS also has three common software virtual key BACK, HOME and RECENT, default tablet mode appear while phone mode should modify code to adapt these keys. framework/base/packages/SystemUI/res/layout/navigation_bar.xml
ICS support multi-panel in tablet mode to fully use advantage of large screen size which is the major difference with former Android version.
Following layout gives us a brief knowledge about ICS UI:
+-------------------------------------------------+
| System bar (only in phone UI) |
+-------------------------------------------------+
| (Layout with background drawable) |
| +---------------------------------------------+ |
| |
Title/Action? bar (optional) |
| +---------------------------------------------+ |
| | Content, vertical extending |
| | |
| +---------------------------------------------+ |
+-------------------------------------------------+
| System bar (only in tablet UI) |
+-------------------------------------------------+
config_statusBarComponent choose which resource we want, statusBar or systemBar.if phone, use com.android.systemui.statusbar.phone.PhoneStatusBar?; while
tablet, use com.android.systemui.statusbar.tablet.TabletStatusBar?. frameworks/base/packages/SystemUI/src/com/android/systemui/SystemUIService.java
public void onCreate() { // Pick status bar or system bar. IWindowManager wm = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); try { SERVICES[0] = wm.canStatusBarHide() ? R.string.config_statusBarComponent : R.string.config_systemBarComponent; } catch (RemoteException e) { Slog.w(TAG, "Failing checking whether status bar can hide", e); }
res/values/config.xml
<string name="config_statusBarComponent" translatable="false"> com.android.systemui.statusbar.phone.PhoneStatusBar</string> <string name="config_systemBarComponent" translatable="false"> com.android.systemui.statusbar.tablet.TabletStatusBar<string>
canStatusBarHide defined inframeworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
public boolean canStatusBarHide() { return mStatusBarCanHide; }
mStatusBarCanHide true or false determine status bar or system bar.
int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / DisplayMetrics.DENSITY_DEVICE; mStatusBarCanHide = shortSizeDp < 600; mStatusBarHeight = mContext.getResources().getDimensionPixelSize( mStatusBarCanHide ? com.android.internal.R.dimen.status_bar_height : com.android.internal.R.dimen.system_bar_height);
Here if shortSizeDp smaller than 600, then system use as tablet mode, otherwise phone mode. DENSITY_DEFAULT is fixed 160. Therefore, 800*480 resolution which compute as 480*160/DENSITY_DEVICE and 800*600 compute as 600*160/DENSITY_DEVICE. So 120 should be
suitable value to make both needs the tablet condition.
setprop ro.sf.lcd_density 120
frameworks/base/core/java/android/content/res/Configuration.java system configuration
public static final int SCREENLAYOUT_SIZE_SMALL = 0x01; public static final int SCREENLAYOUT_SIZE_NORMAL = 0x02; public static final int SCREENLAYOUT_SIZE_LARGE = 0x03; public static final int SCREENLAYOUT_SIZE_XLARGE = 0x04;
ICS also has three common software virtual key BACK, HOME and RECENT, default tablet mode appear while phone mode should modify code to adapt these keys. framework/base/packages/SystemUI/res/layout/navigation_bar.xml
相关文章推荐
- 更新 是 可用的 针对 安卓 软件开发包和工具 Updates are available for android software development packages and tools
- Culture and UI Culture for ASP.NET Web Page
- Android 快速开发框架:推荐10个框架:afinal、ThinkAndroid、andBase、KJFrameForAndroid、SmartAndroid、dhroid..
- [android ui]Android 4.0新增Space及GridLayout初谈
- android 4.0解锁UI修改1
- Android 快速开发框架:推荐10个框架:afinal、ThinkAndroid、andBase、KJFrameForAndroid、SmartAndroid、dhroid..
- Building JavaScript Games for Phones Tablets and Desktop(6)- 响应玩家输入
- An HTTP & HTTP/2 client for Android and Java applications OkHttp
- BlackBerry, iPhone, or Android? Pros and cons of mobile devices for business
- Android UI开发第三十三篇——Navigation Drawer For Android API 7
- Andoid Design-Difference between Android 4.0 and 2.3【整理版】
- A simple guide to 9-patch for Android UI
- Development and remote installation of Java service for the Android Devices
- Free Lua Scripting Interpreter Library For Delphi XE7 Firemonkey On Android And IOS
- Android 混淆报错app:transformClassesAndResourcesWithProguardForRelease
- one key eclipse for android, sdk and ndk
- Android_文档学习_UI_Applying Styles and Themes
- Designing For Android Tablets