page.title=Optimizing Layouts for TV parent.title=Designing for TV parent.link=index.html trainingnavtop=true next.title=Optimizing Navigation for TV next.link=optimizing-navigation-tv.html @jd:body

This lesson teaches you to

  1. Design Landscape Layouts
  2. Make Text and Controls Easy to See
  3. Design for High-Density Large Screens
  4. Design to Handle Large Bitmaps

You should also read

When your application is running on a television set, you should assume that the user is sitting about ten feet away from the screen. This user environment is referred to as the 10-foot UI. To provide your users with a usable and enjoyable experience, you should style and lay out your UI accordingly..

This lesson shows you how to optimize layouts for TV by:

Design Landscape Layouts

TV screens are always in landscape orientation. Follow these tips to build landscape layouts optimized for TV screens:

For example, the following layout is optimized for TV:

In this layout, the controls are on the lefthand side. The UI is displayed within a {@link android.widget.GridView}, which is well-suited to landscape orientation. In this layout both GridView and Fragment have the width and height set dynamically, so they can adjust to the screen resolution. Controls are added to the left side Fragment programatically at runtime. The layout file for this UI is {@code res/layout-land-large/photogrid_tv.xml}. (This layout file is placed in {@code layout-land-large} because TVs have large screens with landscape orientation. For details refer to Supporting Multiple Screens.)

res/layout-land-large/photogrid_tv.xml
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <fragment
        android:id="@+id/leftsidecontrols"
        android:layout_width="0dip"
        android:layout_marginLeft="5dip"
        android:layout_height="match_parent" />

    <GridView        
        android:id="@+id/gridview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>

To set up action bar items on the left side of the screen, you can also include the Left navigation bar library in your application to set up action items on the left side of the screen, instead of creating a custom Fragment to add controls:

LeftNavBar bar = (LeftNavBarService.instance()).getLeftNavBar(this);

When you have an activity in which the content scrolls vertically, always use a left navigation bar; otherwise, your users have to scroll to the top of the content to switch between the content view and the ActionBar. Look at the Left navigation bar sample app to see how to simple it is to include the left navigation bar in your app.

Make Text and Controls Easy to See

The text and controls in a TV application's UI should be easily visible and navigable from a distance. Follow these tips to make them easier to see from a distance :

Design for High-Density Large Screens

The common HDTV display resolutions are 720p, 1080i, and 1080p. Design your UI for 1080p, and then allow the Android system to downscale your UI to 720p if necessary. In general, downscaling (removing pixels) does not degrade the UI (Notice that the converse is not true; you should avoid upscaling because it degrades UI quality).

To get the best scaling results for images, provide them as 9-patch image elements if possible. If you provide low quality or small images in your layouts, they will appear pixelated, fuzzy, or grainy. This is not a good experience for the user. Instead, use high-quality images.

For more information on optimizing apps for large screens see Designing for multiple screens.

Design to Handle Large Bitmaps

The Android system has a limited amount of memory, so downloading and storing high-resolution images can often cause out-of-memory errors in your app. To avoid this, follow these tips: