18 juillet 2012
tvdpi
. As Dianne Hackborn has elaborated, this density might be a surprise to you but don’t panic! We actively discourage you from rushing out and creating new assets at this density; Android will scale your existing assets for you. In fact the entire Jelly Bean OS contains only a single tvdpi
asset, the remainder are scaled down from hdpi
assets. hdpi
assets for tvdpi
, take special care that your 9-patch images are created correctly so that they can be scaled down effectively: The 7” form factor gives you more space to present your content. You can use the sw600dp
resource qualifier to provide alternative layouts for this size screen. For example your application may contain a layout for your launch activity:
res/layout/activity_home.xmlTo take advantage of the extra space on the 7” screen you might provide an alternative layout:
res/layout-sw600dp/activity_home.xmlThe
sw600dp
qualifier declares that these resources are for devices that have a screen with at least 600dp available on its smallest side. res/layout-sw720dp/activity_home.xmlThis technique allows a single application to use defined switching points to respond to a device’s configuration and present an optimized layout of your content.
res/values/dimens.xml
may contain a font size dimension:<dimen name="text_size">18sp</dimen>but you can specify an alternative text size for 7” tablets in
res/values-sw600dp/dimens.xml
:<dimen name="text_size">32sp</dimen>Hardware
android.hardware.camera
feature will not be available on Nexus 7)Be aware of which system features that you declare (or imply) are required to run your application or the Play Store will not make your application available to Nexus 7 users. Always declare hardware features that aren't critical to your app as required="false"
then detect at runtime if the feature is present and progressively enhance functionality. For example if your app can use the camera but it isn’t essential to its operation, you would declare it with:
<uses-feature android:name="android.hardware.camera" android:required="false"/>
For more details follow Reto Meier’s Five Steps to Hardware Happiness.
ConclusionNexus 7 ships with Jelly Bean and its updated suite of system apps are built to take advantage of new Jelly Bean APIs. These apps are the standard against which your application will be judged — make sure that you’re keeping up!
If your application shows notifications then consider utilizing the new richer notification styles. If you are displaying immersive content then control the appearance of the system UI. If you are still using the options menu then move to the Action Bar pattern.
A lot of work has gone into making Jelly Bean buttery smooth; make sure your app is as well. If you haven’t yet opted in to hardware accelerated rendering then now is the time to implement and test this.
For more information on Android 4.1 visit the Android Developers site or join us Live.