游戏邦在:
杂志专栏:
gamerboom.com订阅到鲜果订阅到抓虾google reader订阅到有道订阅到QQ邮箱订阅到帮看

Android平板电脑应用开发的技巧和注意点

发布时间:2011-07-25 13:45:02 Tags:,,

作者:Shane Conder、Lauren Darcey

移动设备厂商正紧锣密鼓地生产新Android设备——平板电脑。苹果iPad的成功证实了用户能够接受此等设备,享受像视频和音频等丰富的消费媒体内容体验。但是这里有个问题,到目前为止,Android应用开发商对于应用的目标平台已形成定势思维,即目标设备是个手机、设备屏幕较小、设备包含Google应用体验。通常来说,这些想法对于平板电脑和其他类型的Android设备并不适用。在这篇文章中,我们将提供某些建议和技巧,以提高你设计和开发未来Android设备杀手级应用的能力。

Android-Tablet(from geeky-gadgets.com)

Android-Tablet(from geeky-gadgets.com)

Android系统能否支持平板电脑

可以说是,也可以说不是。你或许已经了解到,Android已经被移植到许多种设备中,包括电话、烤面包机、微波炉和手提电脑。但是,Android在这些设备上能够运行并不代表用户体验良好或者说此类设备已经为Android社群所认可。

那么Android平板电脑的情况如何呢?Android操作系统开放且自由。设备厂商可以将Android添加到任何设备中,而且许多人已经这么做了。Archos已制作了相当长时间的Android平板电脑。但是,这些设备运行的是较适合平板电脑设备的Android操作系统改良版。直到现在,平板电脑的市场依然较为混乱,但这种情况即将发生改变。

直到近期,谷歌和Open Handset Alliance仍未批准任何Android平板电脑使用Gmail、Maps和最重要的Android Market等Google专利应用。但是,下一代的Android平板电脑的情况将会有所改变。Google已承认在Android SDK和Android Market新版本中将认可平板电脑和其他设备,将这些设备融入Android平台中。今年末至明年初,又有一批新的Android设备将出现在市场上,包括Acer、Dell、Samsung、Toshiba、Viewsonic和Archos等品牌的产品。

开发商急切盼望能够为这些令人振奋的新设备编写应用并确保他们的应用能在设备上流畅运行。问题在于,要如何实现这个目标呢?谷歌已发表声明称,当前Android版本(游戏邦注:即2.2或Froyo)并不适合平板电脑。下个Android版本(游戏邦注:即Gingerbread)有可能会解决存在的某些问题,但开发商在此期间不可只是等待观望。

Android平板电脑的应用设计

当只有一种设备(游戏邦注:即手机)时,上述开发想法或许能够发挥作用,但是这些坏习惯会让你的平板电脑应用开发失败。现在,你必须重新考虑之前的设计想法,更新应用使之与Android平台最新设备兼容,这可以有效确保你的应用为将来的变化做好准备。

好消息在于,为新Android设备开发应用与现有的应用开发的差异并不大。如果设计恰当的话,多数现有的应用都可以在新设备上流畅运行。也就是说,开发商的目标是:

1、应用需要能够精确识别使用supports-screen、uses-configuration、uses-feature和uses-permission等Android Manifest文件标签的应用硬件和软件需求。

2、在使用之前,应当根据硬件、服务和所选择的API来检查应用代码。

3、应用设计师不应将自己的设计想法局限于应用运行的某个具体设备或硬件。

由于并非所有的Android设备都支持蓝牙或WiFi,因而有新型可选API用于这些特殊的设备,包括平板电脑,系统后续版本同样会提供这些服务。在这些API中,有些可能会融合到将来的Android SDK版本(游戏邦注:如Gingerbread)中,而有些可能会是可供产商使用的第三方插件。这些插件可能很像那些现在用于手机上的插件,如用于部分HTC设备的SenseUI或用于部分摩托罗拉设备的MotoBlur。

用户界面设计

在为平板电脑应用设计用户界面时,最好可以让设计的布局灵活可变,使之适宜各种屏幕尺寸、分辨率和方向。这样,无论用户使用的是何种设备,他们都会觉得体验很流畅。以下是设计平板电脑设备应用的用户界面的一些小技巧:

1、保持屏幕简单整洁,确保按键之类的触控点尺寸合适。

2、使用LinearLayout和RelativeLayout等可变的布局控制方式。

3、使用dp和sp等可变的尺寸值。

4、使用可替代性的图像和尺寸资源,为不同的屏幕尺寸、方向比率、像素密度和触屏类型提供与之相适应的资源。

5、使用可替代性的布局和图像资源,为风景和绘制模式提供适宜的资源。

测试应用与Android平板电脑的兼容性

虽然现在已经面世的平板电脑还很少,但你完全可以开始用这些设备来测试现有的应用,解决那些显而易见的问题。在测试应用的兼容性时,你应该记住以下几点:

1、在真实的设备(游戏邦注:而不是模拟器)上进行测试对确保应用达到预期效果至关重要。据报道,像三星Galaxy Tab之类的某些设备,它们的硬件特征与预期的并不相同。比如,尽管先前采用的是中等密度屏幕,三星的新平板电脑据称将使用高密度屏幕,因为这样视觉效果会更好。

2、某些平板电脑可能不含有Google插件,因而确保同样在不含有Google插件的Android虚拟设备(游戏邦注:以下简称AVD)上进行测试。

3、在这些设备中,平板电脑的显示方式稍有不同。确保你的应用在各个手持方向都能够恰当地显示图像。

最后,对于确保应用能够与平板电脑兼容,现在你所能做的最有效的事情就是在带有平板电脑样式AVD配置的模拟器上加载应用,然后看看情况如何。比如,为模拟应用在Galaxy Tab等平板电脑上的运行情况,你可以采用以下步骤来创建AVD配置:

1、启动Android SDK和AVD Manager。

2、点击“新建”。

3、输入平板电脑的名称(游戏邦注:如“Tablet Emu”),并选择合适的SDK版本,如Android 2.2。

4、创建SD卡(游戏邦注:范围在32MB和512MB)之间。

5、点击“皮肤”菜单,选择“分辨率”,在对应的方格内输入“1024”和“600”,设备将启动风景模式。如果你将两个数字对换,启动的就是肖像模式。

6、“Abstracted LCD Density”中可输入任意值,推荐120、160和240。为模拟Galaxy Tab的真实屏幕密度,我们输入170。设备被定义为中密度显示。如果要模拟未来的高密度显示,我们可以输入240。

7、选择“创建AVD”。

8、创建完成后,点击“开始”按键运行。

9、如果显示尺寸过大,你可以考虑用初始像素将其缩小。

Android_Tablet_Figure1(from developer.com)

Android_Tablet_Figure1(from developer.com)

上图显示的是应用在模拟平板电脑的自定义AVD上的显示状况,它还比较了中密度显示和同等像素分辨率下高密度显示的差异。因为密度不同,每屏上的按键的尺寸也有所不同。但是,中密度显示上有许多浪费的屏幕空间。这不仅是个显示为何Android还不是很适合大屏幕平板电脑的例证,而且还显示出为何设备产商要改变显示密度。

未来状况

如果传言属实,下个版本的Android SDK将开始以较为官方的方法来处理某些设备差异问题。期望能看到诸如用于可选择硬件的额外API、用于目标设备特征的Android Manifest配置选项更新以及新控制和屏幕布局选项等改变。我们也很希望Android Market也能够做出适当的改变。比如,Google方面已经暗示称,将来Android Market可能使用某些应用许可权限来过滤不适宜设备的应用。

未来可能出现各种Android设备,如电话、PDA、音乐播放器、平板电脑和烤面包机。现在,作为一个应用开发者,你可以开始沿着这个发展路线来思考。在开发应用时,应当注意下自己的想法和技巧,考虑它们可否限制或允许应用在其他设备上运行。检查你的现有应用,用更为灵活可变的用户界面来更新,根据设备功能和特征做出更有先见之明的举动。

Android平板电脑的出现使得开发商可以有个全新的设备来定位他们的应用。Android平板电脑未来可能发展出更大更高分辨率的触屏、视频输出选择、前视摄像头以及其他的硬件功能,而且价格较为合理。这些功能可以让开发商依次编写出新式应用,进驻新市场。为平板电脑开发应用需要更多有前瞻性的想法,而且这些设计原则几乎可用于所有的目标设备应用开发中。

游戏邦注:本文发稿于2010年10月25日,所涉时间、事件和数据均以此为准。(本文为游戏邦/gamerboom.com编译,如需转载请联系:游戏邦

Building Killer Android Tablet Apps: Design and Development Tips

Shane Conder, Lauren Darcey

Device manufacturers are ramping up an exciting new line of Android devices: tablets. The success of the Apple iPad has proven that consumers are ready for these devices, which make consuming media content like video and audio a rich and enjoyable experience. But there’s a catch: until now, Android developers have made certain assumptions about the target devices their apps run on — assumptions like “the device is a phone,” “the device has a small screen” and “the device includes the Google app experience.” These assumptions will not always hold true for tablets and other types of Android-powered devices. In this article, we offer some tips and tricks for ramping up your skills to design and develop killer apps for the Android devices of the future.

Android Supports Tablets?

Yes, and no. You may be aware that Android has been ported to many kinds of devices, including phones, toasters, microwaves and laptops. However, just because Android runs on these devices doesn’t mean the user experience is great or the device is officially recognized by the Android community.

So what about the Android tablets that are already in users’ hands? Well, the Android operating system is open and free. Manufacturers can put Android on whatever devices they want to, and many have. Archos has been making Android tablets for quite some time. However, these devices run a modified version of the Android OS that has been tuned for the tablet device. Until now, tablets have been something of a gray market, but that’s about to change.

Until recently, Google and the Open Handset Alliance have not approved any Android tablets for use with Google proprietary applications such as Gmail, Maps, and most importantly, the Android Market. This will change with the next wave of Android tablets; Google has acknowledged that tablets and other devices will be recognized and incorporated into the Android platform in future versions of the Android SDK and the Android Market. Now, there’s a wave of new Android-powered devices slated to hit the shelves late this year and early next year from the likes of Acer, Dell, Samsung, Toshiba, Viewsonic, Archos and more.

Developers are eager to write apps for these exciting new devices and ensure that their existing apps will run smoothly. The question is: how? Google has made a statement to the effect that the current version of Android (2.2, or Froyo) is not designed for tablets. The next version of Android (Gingerbread) is likely to address some of these issues, but developers need not wait to start preparing for the onslaught of Android tablets.

Application Design for Android Tablets

Lazy development assumptions may have worked when there was really only one type of device (a phone), but these bad habits may come back and bite you when your app is deployed on a device like a tablet. Reconsider previous design decisions now and update your applications to make them compliant with the latest configuration options available on the Android platform to help ensure that your application is ready for the future.

The good news is that developing for new Android devices isn’t going to be that different from developing for existing ones. Most existing apps will run well enough, provided they’ve been designed prudently, by which we mean:

The app properly identifies its application hardware and software requirements using the Android Manifest file tags such as supports-screen, uses-configuration, uses-feature and uses-permission.

The app code checks for hardware, services and optional APIs before attempting to use them.

The app designers minimized the assumptions about which exact devices or hardware the application would run on.

Just as not all Android devices support Bluetooth or WiFi, there are — and will continue to be — new optional APIs for working with specific devices, including tablets. Some of these APIs may be baked into future versions of the Android SDK (like Gingerbread) while others may be third-party add-ons available from manufacturers. These may be similar to such add-ons available for current handsets; the SenseUI is available for some but not all HTC devices, or MotoBlur on some but not all Motorola devices.

User Interface Design for Tablets

When it comes to designing user interfaces for tablets, it’s best to stick with flexible layout designs that will scale well to various screen sizes, resolutions and orientations. This way, users will find the experience familiar, regardless of what type of device they use. Here are some tips for designing user interfaces for tablet devices:

Keep screens streamlined and uncluttered and ensure touch controls such as buttons are of adequate size.

Use flexible layout controls such as LinearLayout and RelativeLayout as opposed to pixel-perfect ones such as AbsoluteLayout.

Use flexible dimension values like dp and sp instead of px or pt.

Use alternative resources such as graphic and dimension resources to provide specialized resources for different screen sizes, aspect ratios, pixel densities and touchscreen types.

Use alternative resources such as layout and graphic resources to provide specialized resources for landscape and portrait modes.

Testing Apps for Android Tablet Compatibility

Although few tablets have been released yet, nothing is stopping you from beginning to test your existing apps and ironing out the obvious issues. Here are some tips to keep in mind when testing for tablet compatibility:

Testing on the actual devices (as opposed to the emulator) will be critical to ensuring your application behaves as expected. Some devices, such as Samsung’s Galaxy Tab, have reported their hardware characteristics differently than expected. For example, despite having a medium-density screen, Samsung chose to have its new tablet report as a high-density screen because it looks better (see Figure 1).

Some tablets may not include the Google “experience,” so make sure you also test with Android Virtual Devices (AVDs) that do not include the Google add-ons.

Tablets, among other devices, are beginning to take a landscape-first approach to the screen. Make sure your app displays properly in both orientations and handles orientation changes correctly (see this Android Developer Blog post for details).

Finally, one of the best things you can do right now to ensure your app is tablet compliant is load your app into the emulator with a tablet-style AVD configuration and see how it behaves. For example, use the following steps to create an AVD configuration that mimics how your application would display on a tablet much like the upcoming Galaxy Tab:

Launch the Android SDK and AVD Manager.

Press the New… button.

Enter a name for the tablet (e.g. “Tablet Emu”) and choose an appropriate SDK version, such as Android 2.2.

Create an SD card (We use between 32MB and 512MB).

For the Skin section, choose Resolution and enter “1024″ and “600″ into the appropriate boxes. If you enter 1024 then 600, the device will start in landscape mode. If you enter 600 then 1024, it will start in portrait mode.

For the Abstracted LCD Density, any value will work (although the values 120, 160 and 240 are suggested). To mimic the actual screen density of the Galaxy Tab, enter 170. The device will be treated as a medium-density display. To mimic the reported screen density, enter 240. The device will be treated as having a high-density display.

Choose Create AVD.

When it’s created, launch it with the Start… button.

As the display size is rather large, you may wish to scale it down using the launch parameters.

Figure 1 below illustrates how an application might appear on a custom AVD to mimic a tablet. It also demonstrates the difference between a medium-density display with the same pixel resolution as a high-density display. Because the density is different, the buttons on each screen actually draw at the same size. The medium-density display, however, shows a lot of wasted screen space. This not only demonstrates one example of why Android isn’t quite ready for larger screen tablets, but also shows why a manufacturer might want to report a different value.

Stay Tuned

If the rumors are true, the next major release of the Android SDK (Gingerbread) will begin to address some of the device differences in some official manner. Expect to see changes such as additional APIs for optional hardware, updates to the Android Manifest configuration options available for targeting specific device characteristics, and perhaps new controls and screen layout options. We are also likely to see changes to the Android Market to reflect the plethora of devices about to reach consumers’ hands. For example, sources at Google have implied that certain application permissions (as defined in the Android Manifest file using the tag) may be used by the Android Market to filter apps for devices in the future.

In that future, Android-powered devices will likely come in many forms: phones, PDAs, music players, tablets and toasters. For now, one of the best things you can do as a developer is start to think along these lines. Be mindful of the assumptions you make when developing your apps, and consider how they will restrict or allow your apps to run on different types of devices. Review your existing apps and update them with more flexible user interfaces and prudent assertions on device features and characteristics.

With the introduction of Android tablets, developers now have a whole new range of devices to target with their applications. Android tablets are likely to boast larger and higher-resolution touchscreens, video output options, front-facing cameras and other optional hardware features — at very reasonable prices. These features enable developers to write new kinds of applications and enter new markets. Developing Android apps for tablets requires some forethought, but many of the design principles for writing great Android apps for tablets really apply to all device targets. (Source: Developer)


上一篇:

下一篇: