summaryrefslogtreecommitdiffstats
path: root/docs/html/preview
diff options
context:
space:
mode:
authorJoe Fernandez <joefernandez@google.com>2014-09-11 09:52:07 -0700
committerJoe Fernandez <joefernandez@google.com>2014-10-12 17:29:44 -0700
commitd86a2f5b344a6c3520ab05c02df8a5b3fdfa5aea (patch)
treeec6dc0ac024e84e5d288165dab2c7357f59eb736 /docs/html/preview
parentbbbeafa9bf0c4598b32c615c72e2c87ef62c85e9 (diff)
downloadframeworks_base-d86a2f5b344a6c3520ab05c02df8a5b3fdfa5aea.zip
frameworks_base-d86a2f5b344a6c3520ab05c02df8a5b3fdfa5aea.tar.gz
frameworks_base-d86a2f5b344a6c3520ab05c02df8a5b3fdfa5aea.tar.bz2
docs: Android TV App Dev Basic Training
Change-Id: Iede448652efba25c3d0b6c26d49ea6548008515e
Diffstat (limited to 'docs/html/preview')
-rw-r--r--docs/html/preview/tv/start/hardware-features.jd183
-rw-r--r--docs/html/preview/tv/start/index.jd237
-rw-r--r--docs/html/preview/tv/ui/layouts.jd298
-rw-r--r--docs/html/preview/tv/ui/navigation.jd136
4 files changed, 0 insertions, 854 deletions
diff --git a/docs/html/preview/tv/start/hardware-features.jd b/docs/html/preview/tv/start/hardware-features.jd
deleted file mode 100644
index ddec496..0000000
--- a/docs/html/preview/tv/start/hardware-features.jd
+++ /dev/null
@@ -1,183 +0,0 @@
-page.title=Hardware Features on TV
-page.tags="unsupported"
-
-@jd:body
-
-<div id="qv-wrapper">
-<div id="qv">
- <h2>In this document</h2>
- <ol>
- <li><a href="#unsupported-features">Unsupported Hardware Features</a></li>
- <li><a href="#workaround-features">Handling Unsupported Features</a></li>
- <li><a href="#check-features">Checking Available Features</a>
- <ol>
- <li><a href="#no-touchscreen">Touch screen</a></li>
- <li><a href="#no-camera">Camera</a></li>
- <li><a href="#no-gps">GPS</a></li>
- </ol>
-
- </li>
- </ol>
-</div>
-</div>
-
-<p>TVs do not have some of the hardware features found on other Android devices.
-Touch screens, cameras, and GPS receivers are some of the most commonly used hardware features
-which are typically not available on a TV. When you build an app for TV, you must carefully
-consider if your app can handle not having these features and, if necessary, work around them.</p>
-
-<p>This guide discusses the hardware features not available on TV devices and shows you how to
-work around those limitations in your app. For more information on filtering and declaring
-features in the manifest, see the
-<a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">uses-feature</a> guide.</p>
-
-
-<h2 id="unsupported-features">Unsupported Hardware Features</h2>
-
-<p>TVs have a different purpose from other devices, and so they do not have hardware
-features that other Android-powered devices often have. For this reason, the Android system
-does not support the following features for a TV device:
-
-<table>
-<tr>
-<th>Hardware</th>
-<th>Android feature descriptor</th>
-</tr>
-<tr>
-<td>Camera</td>
-<td>android.hardware.camera</td>
-</tr>
-<tr>
-<td>GPS</td>
-<td>android.hardware.location.gps</td>
-</tr>
-<tr>
-<td>Microphone</td>
-<td>android.hardware.microphone</td>
-</tr>
-<tr>
-<td>Near Field Communications (NFC)</td>
-<td>android.hardware.nfc</td>
-</tr>
-<tr>
-<td>Telephony</td>
-<td>android.hardware.telephony</td>
-</tr>
-<tr>
-<td>Touchscreen</td>
-<td>android.hardware.touchscreen</td>
-</tr>
-</table>
-</p>
-
-
-<h2 id="check-features">Checking Available Features</h2>
-
-<p>To check if a feature is available at runtime, call {@link
- android.content.pm.PackageManager#hasSystemFeature(String)}. This method takes a single string
- argument that specifies the feature you want to check. For example, to check for a touch screen,
- use {@link android.content.pm.PackageManager#hasSystemFeature(String)} with the argument
- {@link android.content.pm.PackageManager#FEATURE_TOUCHSCREEN}.</p>
-
-<p>The following code example demonstrates how to detect the availability of a hardware features
- at runtime:</p>
-
-<pre>
-// Check if the telephony hardware feature is available.
-if (getPackageManager().hasSystemFeature("android.hardware.telephony")) {
- Log.d("Mobile Test", "Running on phone");
-// Check if android.hardware.touchscreen feature is available.
-} else if (getPackageManager().hasSystemFeature("android.hardware.touchscreen")) {
- Log.d("Tablet Test", "Running on devices that don't support telephony but "+
- "do have a touch screen.");
-} else {
- Log.d("TV Test", "Running on a TV!");
-}
-</pre>
-
-<p class="note">
- <strong>Note:</strong> You can also use the {@link android.app.UiModeManager#getCurrentModeType
- UiModeManager.getCurrentModeType()} method to detect the current platform type. For TV devices,
- this method returns a value of {@link android.content.res.Configuration#UI_MODE_TYPE_TELEVISION
- Configuration.UI_MODE_TYPE_TELEVISION}.
-</p>
-
-
-<h2 id="workaround-features">Handling Unsupported Features</h2>
-
-<p>Depending on the design and functionality of your app, you may be able to work around certain
- hardware features being unavailable. This section discusses how to work around specific hardware
- features.</p>
-
-
-<h3 id="no-touchscreen">Touch screen</h3>
-
-<p>Android doesn't support touch screen interaction for TV devices, since most TVs don't have touch
- screens, and using a touch screen is not consistent with a viewing environment where the user is
- seated 10 feet away from the display.</p>
-
-<p>On TV devices, you should work around this limitation by supporting navigation using a directional
- pad (D-pad) on TV remote control. For more information on properly supporting navigation using
- TV-friendly controls, see <a href="{@docRoot}preview/tv/ui/navigation.html">Navigation for
- TV</a>.</p>
-
-<p>You can explicitly declare if your application requires (or does not require) a touch screen
- by including the following entry in your manifest:</p>
-
-<pre>
-&lt;uses-feature android:name="android.hardware.touchscreen"
- android:required="false"/&gt;
-</pre>
-
-
-<h3 id="no-camera">Camera</h3>
-
-<p>Although a TV typically does not have a camera, you can still provide a photography-related
- application on a TV. For example, if you have an app that takes, views and edits photos, you can
- disable its picture-taking functionality for TVs and still allow users to view and even edit
- photos. If you decide that you want to enable your camera-related application to work on a
- TV device without a camera, you can add an attribute to your app manifest declaring that
- a camera is not required by your app:</p>
-
-<pre>
-&lt;uses-feature android:name="android.hardware.camera" android:required="false" /&gt;
-</pre>
-
-<p>If you enable your application to run without a camera, you should add code to your application
-that detects if the camera feature is available and makes adjustments to the operation of your app.
-The following code example demonstrates how to detect the presence of a camera:</p>
-
-<pre>
-// Check if the camera hardware feature is available.
-if (getPackageManager().hasSystemFeature("android.hardware.camera")) {
- Log.d("Camera test", "Camera available!");
-} else {
- Log.d("Camera test", "No camera available. View and edit features only.");
-}
-</pre>
-
-
-<h3 id="no-gps">GPS</h3>
-
-<p>TVs are stationary, indoor devices, and do not have built-in global positioning system (GPS)
- receivers. If your application uses location information, you can still allow users to search
- for a location, or use a static location provider such as a zip code configured during the
- TV device setup.</p>
-
-<pre>
-LocationManager locationManager = (LocationManager) this.getSystemService(
- Context.LOCATION_SERVICE);
-Location location = locationManager.getLastKnownLocation("static");
-Geocoder geocoder = new Geocoder(this);
-Address address = null;
-
-try {
- address = geocoder.getFromLocation(location.getLatitude(),
- location.getLongitude(), 1).get(0);
- Log.d("Zip code", address.getPostalCode());
-
-} catch (IOException e) {
- Log.e(TAG, "Geocoder error", e);
-}
-</pre>
-
diff --git a/docs/html/preview/tv/start/index.jd b/docs/html/preview/tv/start/index.jd
deleted file mode 100644
index 8081995..0000000
--- a/docs/html/preview/tv/start/index.jd
+++ /dev/null
@@ -1,237 +0,0 @@
-page.title=Get Started with TV Apps
-page.tags="leanback","recyclerview","launcher"
-
-@jd:body
-
-<div id="qv-wrapper">
-<div id="qv">
- <h2>In this document</h2>
- <ol>
- <li><a href="#prerequisites">Prerequisites</a></li>
- <li><a href="#dev-project">Setup a TV Project</a>
- <ul>
- <li><a href="#tv-activity">Create a TV Activity</a></li>
- <li><a href="#tv-libraries">Add TV Support Libraries</a></li>
- </ul>
- </li>
- <li><a href="#build-it">Build TV Apps</a></li>
- <li><a href="#run">Run TV Apps</a></li>
-
- </ol>
-</div>
-</div>
-
-<p>This guide describes how to prepare your development environment and projects for building
- TV apps, including updating your existing app to run on TV devices.</p>
-
-<p class="note">
- <strong>Important:</strong> There are specific requirements your app must meet in order to
- qualify as an Android TV app on Google Play. For more information, see the requirements listed
- in <a href="{@docRoot}preview/tv/publish/index.html">Publishing TV Apps</a>.
-</p>
-
-
-<h2 id="prerequisites">Prerequisites</h2>
-
-<p>Before you begin setting up to build apps for TV, you must:</p>
-
-<ul>
- <li><strong><a href="{@docRoot}preview/setup-sdk.html">
- Set up the Preview SDK</a></strong>
- <br>
- The preview SDK provides the developer tools needed to build and test apps for TV.
- </li>
- <li><strong><a href="{@docRoot}preview/setup-sdk.html#project">
- Create a Preview SDK Project</a></strong>
- <br>
- In order to access new APIs for TV devices, you must create a project that targets the preview
- release level or modify an existing project to target the preview release.
- </li>
-</ul>
-
-
-<h2 id="dev-project">Set up a TV Project</h2>
-
-<p>TV apps use the same structure as those for phones and tablets. This means you can modify
- your existing apps to also run on TV devices or create new apps based on what you already know
- about building apps for Android. This section discusses how to modify an existing app, or create a
- new one, to run on TV devices.</p>
-
-<p>These are the main steps to creating an app that runs on TV devices. Only the first
- is required:</p>
-
-<ul>
- <li><strong>Activity for TV</strong> - (Required) In your application manifest, you must
- declare an activity that is intended to run on TV devices.</li>
- <li><strong>TV Support Libraries</strong> - (Optional) There are several Support Libraries
- available for TV devices that provide widgets for building user interfaces.</li>
-</ul>
-
-
-<h3 id="tv-activity">Create a TV Activity</h3>
-
-<p>An application intended to run on TV devices must declare a launcher activity for TV
- in its manifest using a {@code android.intent.category.LEANBACK_LAUNCHER} intent filter.
- This filter identifies your app as being built for TV, enabling it to be displayed in the
- Google Play store app running on TV devices. Declaring this intent also identifies which activity
- in your app should be launched when a user selects its icon on the TV home screen.</p>
-
-<p class="caution">
- <strong>Caution:</strong> If you do not include the {@code LEANBACK_LAUNCHER} intent filter in
- your app, it is not visible to users running the Google Play store on TV devices. Also, if your
- app does not have this filter when you load it onto a TV device using developer tools, the app
- does not appear in the TV user interface.
-</p>
-
-<p>The following code snippet shows how to include this intent filter in your manifest:</p>
-
-<pre>
-&lt;application&gt;
- ...
- &lt;activity
- android:name=&quot;com.example.android.MainActivity&quot;
- android:label=&quot;@string/app_name&quot; &gt;
-
- &lt;intent-filter&gt;
- &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
- &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
- &lt;/intent-filter&gt;
- &lt;/activity&gt;
-
- &lt;activity
- android:name=&quot;com.example.android.<strong>TvActivity</strong>&quot;
- android:label=&quot;&#64;string/app_name&quot;
- android:theme=&quot;&#64;style/Theme.Leanback&quot;&gt;
-
- &lt;intent-filter&gt;
- &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
- &lt;category android:name="<strong>android.intent.category.LEANBACK_LAUNCHER</strong>" /&gt;
- &lt;/intent-filter&gt;
-
- &lt;/activity&gt;
-&lt;/application&gt;
-</pre>
-
-<p>The second activity manifest entry in the example above specifies that activity as
- the main one when your app launches on an TV device.</p>
-
-<p>If you have an existing app that you are modifying for TV use, your app should not use the same
- activity layout for TV that it does for phones and tablets. The user interface of your TV app (or
- TV portion of your existing app) should provide a simpler interface that can be easily navigated
- using a remote control from a couch. For guidelines on designing an app for TV, see the
- <a href="{@docRoot}design/tv/index.html">TV Design</a> guide. For more instructions on
- developing a user interface appropriate to TV, see the
- <a href="{@docRoot}preview/tv/ui/index.html">TV User Interface</a> guide.
-</p>
-
-
-<h3 id="tv-libraries">Add TV Support Libraries</h3>
-
-<p>The Preview SDK includes support libraries that are intended for use with TV apps. These
- libraries provide APIs and user interface widgets for use on TV devices. The libraries are
- located in the {@code &lt;sdk&gt;/extras/android/support/} directory where you installed the
- Preview SDK. Here is a list of the libraries and their general purpose:</p>
-
-<ul>
- <li><strong>v17 leanback library</strong> - Provides user interface widgets for TV, including
- {@code BrowseFragment}, {@code DetailsFragment}, and {@code SearchFragment}.
- <ul>
- <li>SDK location: {@code &lt;sdk&gt;/extras/android/support/v17/leanback}</li>
- <li>Gradle dependency: {@code com.android.support:leanback-v17:20.0.+}</li>
- <li>Contains resources: Yes</li>
- </ul>
- </li>
- <li><strong>v7 recyclerview library</strong> - Provides classes for managing display of long
- lists in a memory efficient manner. Several classes in the v17 leanback library depend on the
- classes in this library.
- <ul>
- <li>SDK location: {@code &lt;sdk&gt;/extras/android/support/v7/recyclerview}</li>
- <li>Gradle dependency: {@code com.android.support:recyclerview-v7:20.0.+}</li>
- <li>Contains resources: No</li>
- </ul>
- </li>
-</ul>
-
-<p class="note">
- <strong>Note:</strong> You are not required to use these support libraries for your TV app.
- However, we strongly recommend using them, particularly for apps that provide a media catalog
- browsing interface.
-</p>
-
-<p>If you decide to use the v17 leanback library for your app, you should note that it is
- dependent on the
- <a href="{@docRoot}tools/support-library/features.html#v4">v4 support library</a>. This means
- that apps that use the leanback support library should include all of these support
- libraries:</p>
-
-<ul>
- <li>v17 leanback support library</li>
- <li>v7 recyclerview support library</li>
- <li>v4 support library</li>
-</ul>
-
-<p>The v17 leanback library contain resources, which requires
- you to take specific steps to include it in app projects. For instructions on
- importing a support library with resources, see
- <a href="http://developer.android.com/tools/support-library/setup.html#libs-with-res">
- Support Library Setup</a>.
-</p>
-
-
-<h2 id="build-it">Build TV Apps</h2>
-
-<p>After you have completed the steps described above, it's time to start building apps for
- the big screen! Check out these additional topics to help you build your app for TV:
-
-<ul>
- <li><a href="{@docRoot}preview/tv/ui/index.html">User Interface</a> - The user interface of
- TV devices is different from those of other Android devices. See this topic to find out how
- to build TV user interfaces and to learn about the widgets provided to simplify that task.
- </li>
- <li><a href="{@docRoot}preview/tv/games/index.html">Games for TV</a> - TV devices are great
- platforms for games. See this topic for information on building great game experiences for
- TV.</li>
- <li><a href="{@docRoot}preview/tv/start/hardware-features.html">Hardware features</a> - TV
- devices do not contain hardware features normally found on other Android devices. See this
- topic for information on unsupported hardware features and what to do about them.
- </li>
-</ul>
-
-
-<h2 id="run">Run TV Apps</h2>
-
-<p>Running your app is an important part of the development process. The AVD Manager in the
- Android SDK provides the device definitions that allows you to create virtual TV devices for
- running and testing your applications.</p>
-
-<p>To create an virtual TV device:</p>
-
-<ol>
- <li>Start the AVD Manager. For more information, see the
- <a href="{@docRoot}tools/help/avd-manager.html">AVD Manager</a> help.</li>
- <li>In the AVD Manager dialog, click the <strong>Device Definitions</strong> tab.</li>
- <li>Select one of the Android TV device definitions, such as
- <strong>Large Android TV</strong>, and click <strong>Create AVD</strong>.</li>
- <li>Select the emulator options and click <strong>OK</strong> to create the AVD.
- <p class="note">
- <strong>Note:</strong> For best performance of the TV emulator device, enable the <strong>Use
- Host GPU</strong> option and CPU platform image that supports hardware acceleration. For
- more information on hardware acceleration of the emulator, see
- <a href="{@docRoot}tools/devices/emulator.html#acceleration">Using the Emulator</a>.
- </p>
- </li>
-</ol>
-
-<p>To test your application on the virtual TV device:</p>
-
-<ol>
- <li>Compile your TV application in your development environment.</li>
- <li>Run the application from your development environment and choose the TV virtual device as
- the target.</li>
-</ol>
-
-<p>For more information about using emulators see, <a href="{@docRoot}tools/devices/emulator.html">
-Using the Emulator</a>. For more information about deploying apps to emulators from
-Eclipse with ADT, see <a href="{@docRoot}http://developer.android.com/tools/building/building-eclipse.html">
-Building and Running from Eclipse with ADT</a>.</p>
-
diff --git a/docs/html/preview/tv/ui/layouts.jd b/docs/html/preview/tv/ui/layouts.jd
deleted file mode 100644
index b9ca7b9..0000000
--- a/docs/html/preview/tv/ui/layouts.jd
+++ /dev/null
@@ -1,298 +0,0 @@
-page.title=Layouts for TV
-
-@jd:body
-
-<div id="qv-wrapper">
-<div id="qv">
- <h2>In this document</h2>
- <ol>
- <li><a href="#themes">Themes</a>
- <ol>
- <li><a href="#leanback-theme">Leanback Theme</a></li>
- <li><a href="#notitle-theme">NoTitleBar Theme</a></li>
- </ol>
- </li>
- <li><a href="#structure">Layout Structure</a>
- <ol>
- <li><a href="#overscan">Overscan</a></li>
- </ol>
- </li>
- <li><a href="#visibility">Text and Controls Visibility</a></li>
- <li><a href="#density-resources">Screen Density and Image Resources</a></li>
- <li><a href="#anti-patterns">Layout Anti-Patterns</a></li>
- <li><a href="#large-bitmaps">Handling Large Bitmaps</a></li>
- </ol>
-
-</div>
-</div>
-
-<p>
- A TV screen is typically viewed from about 10 feet away, and while it is much larger than most
- other Android device displays, this type of screen does not provide the same level of precise
- detail and color as a smaller device. These factors require that you create app layouts with
- TV devices in mind in order to create a useful and enjoyable user experience.</p>
-
-<p>This guide provides direction and implementation details for building effective layouts inN
- TV apps.</p>
-
-
-<h2 id="themes">Themes</h2>
-
-<p>Android <a href="{@docRoot}guide/topics/ui/themes.html">Themes</a> can provide a basis for
- layouts in your TV apps. You should use a theme to modify the display of your app activities
- that are meant to run on a TV device. This section explains which themes you should use.</p>
-
-
-<h3 id="leanback-theme">Leanback Theme</h3>
-
-<p>The Leanback library provides a standard theme for TV activities, called {@code
- Theme.Leanback}, which establishes a consistent visual style for TV apps. Use of this theme is
- recommended for most apps. This theme is recommended for any TV app that uses the Leanback
- library classes. The following code sample shows how to apply this theme to a given
- activity within an app:</p>
-
-<pre>
-&lt;activity
- android:name="com.example.android.TvActivity"
- android:label="&#64;string/app_name"
- <strong>android:theme="&#64;style/Theme.Leanback"</strong>&gt;
-</pre>
-
-
-<h3 id="notitle-theme">NoTitleBar Theme</h3>
-
-<p>The title bar is a standard user interface element for Android apps on phones and tablets,
- but it is not appropriate for TV apps. If you are not using the Leanback library classes,
- you should apply this theme to your TV activities. The following code example from a TV app
- manifest demonstrates how to apply this theme to remove the display of a title bar:
-</p>
-
-<pre>
-&lt;application&gt;
- ...
-
- &lt;activity
- android:name="com.example.android.TvActivity"
- android:label="&#64;string/app_name"
- <strong>android:theme="&#64;android:style/Theme.NoTitleBar"</strong>&gt;
- ...
-
- &lt;/activity&gt;
-&lt;/application&gt;
-</pre>
-
-
-<h2 id="structure">Layout Structure</h2>
-
-<p>Layouts for TV devices should follow some basic guidelines to ensure they are usable and
- effective on large screens. Follow these tips to build landscape layouts optimized for TV screens:
-</p>
-
-<ul>
- <li>Build layouts with a landscape orientation. TV screens always display in landscape.</li>
- <li>Put on-screen navigation controls on the left or right side of the screen and save the
- vertical space for content.</li>
- <li>Create UIs that are divided into sections, using <a
- href="{@docRoot}guide/components/fragments.html"
- >Fragments</a>, and use view groups like {@link android.widget.GridView} instead of {@link
- android.widget.ListView} to make better use of the horizontal screen space.
- </li>
- <li>Use view groups such as {@link android.widget.RelativeLayout} or {@link
- android.widget.LinearLayout} to arrange views. This approach allows the system to adjust the
- position of the views to the size, alignment, aspect ratio, and pixel density of a TV screen.</li>
- <li>Add sufficient margins between layout controls to avoid a cluttered UI.</li>
-</ul>
-
-
-<h3 id="overscan">Overscan</h3>
-
-<p>Layouts for TV have some unique requirements due to the evolution of TV standards and the
- desire to always present a full screen picture to viewers. For this reason, TV devices may
- clip the outside edge of an app layout in order to ensure that the entire display is filled.
- This behavior is generally referred to as Overscan.</p>
-
-<p>In order to account for the impact of overscan and make sure that all the user interface
- elements you place in a layout are actually shown on screen, you should incorporate a 10% margin
- on all sides of your layout. This translates into a 27dp margin on the left and right edges and
- a 48dp margin on the top and bottom of your base layouts for activities. The following
- example layout demonstrates how to set these margins in the root layout for a TV app:
-</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/base_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:layout_marginTop="27dp"
- android:layout_marginLeft="48dp"
- android:layout_marginRight="48dp"
- android:layout_marginBottom="27dp" &gt;
-&lt;/LinearLayout&gt;
-</pre>
-
-<p class="caution">
- <strong>Caution:</strong> Do not apply overscan margins to your layout if you are using the
- Leanback Support Library {@code BrowseFragment} or related widgets, as those layouts already
- incorporate overscan-safe margins.
-</p>
-
-
-<h2 id="visibility">Text and Controls Visibility</h2>
-
-<p>
-The text and controls in a TV app layout should be easily visible and navigable from a distance.
-Follow these tips to make them easier to see from a distance :
-</p>
-
-<ul>
- <li>Break text into small chunks that users can quickly scan.</li>
- <li>Use light text on a dark background. This style is easier to read on a TV.</li>
- <li>Avoid lightweight fonts or fonts that have both very narrow and very broad strokes.
- Use simple sans-serif fonts and anti-aliasing to increase readability.</li>
- <li>Use Android's standard font sizes:
-<pre>
-&lt;TextView
- android:id="@+id/atext"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:singleLine="true"
- android:textAppearance="?android:attr/textAppearanceMedium"/&gt;
-</pre>
- </li>
- <li>Ensure that all your view widgets are large enough to be clearly visible to someone
- sitting 10 feet away from the screen (this distance is greater for very large screens). The
- best way to do this is to use layout-relative sizing rather than absolute sizing, and
- density-independent pixel units instead of absolute pixel units. For example, to set the
- width of a widget, use wrap_content instead of a pixel measurement, and to set the margin
- for a widget, use dip instead of px values.</li>
-</ul>
-
-
-<h2 id="density-resources">Screen Density and Image Resources</h2>
-
-<p>The common high-definition TV display resolutions are 720p, 1080i, and 1080p.
- Your TV layout should target a screen size of 1920 x 1080 pixels, and then allow the Android
- system to downscale your layout elements to 720p if necessary. In general, downscaling
- (removing pixels) does not degrade your layout presentation quality. However, upscaling can
- cause display artifacts that degrade the quality of your layout and have a negative impact on
- the user experience of your app.</p>
-
-<p>
- To get the best scaling results for images, provide them as
- <a href="{@docRoot}tools/help/draw9patch.html">9-patch image</a> 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.
-</p>
-
-<p>
- For more information on optimizing layouts and resources for large screens see
- <a href="{@docRoot}training/multiscreen/index.html">Designing for multiple screens</a>.
-</p>
-
-
-<h2 id="anti-patterns">Layout Anti-Patterns</h2>
-
-<p>There are a few approaches to building layouts for TV that you should avoid because they do not
-work well and lead to bad user experiences. Here are some user interface approaches you
-should specifically <em>not</em> use when developing a layout for TV.
-</p>
-
-<ul>
- <li><strong>Re-using phone or tablet layouts</strong> - Do not reuse layouts from a phone or
- tablet app without modification. Layouts built for other Android device form factors are not
- well suited for TV devices and should be simplified for operation on a TV.</li>
- <li><strong>ActionBar</strong> - While this user interface convention is recommended for use
- on phones and tablets, it is not appropriate for a TV interface. In particular, using an
- action bar options menu (or any pull-down menu for that matter) is strongly discouraged, due
- to the difficulty in navigating such a menu with a remote control.</li>
- <li><strong>ViewPager</strong> - Sliding between screens can work great on a phone or tablet,
- but don't try this on a TV!</li>
-
-</ul>
-
-<p>For more information on designing layouts that are appropriate to TV, see the
- <a href="{@docRoot}design/tv/index.html">TV Design</a> guide.</p>
-
-
-<h2 id="large-bitmaps">Handling Large Bitmaps</h2>
-
-<p>TV devices, like any other Android device, have a limited amount of memory. If you build your
- app layout with very high-resolution images or use many high-resolution images in the operation
- of your app, it can quickly run into memory limits and cause out of memory errors.
- To avoid these types of problems, follow these tips:</p>
-
-<ul>
- <li>Load images only when they're displayed on the screen. For example, when displaying multiple images in
- a {@link android.widget.GridView} or
- {@link android.widget.Gallery}, only load an image when
- {@link android.widget.Adapter#getView(int, View, ViewGroup) getView()}
- is called on the View's {@link android.widget.Adapter}.
- </li>
- <li>Call {@link android.graphics.Bitmap#recycle()} on
- {@link android.graphics.Bitmap} views that are no longer needed.
- </li>
- <li>Use {@link java.lang.ref.WeakReference} for storing references
- to {@link android.graphics.Bitmap} objects in an in-memory
- {@link java.util.Collection}.</li>
- <li>If you fetch images from the network, use {@link android.os.AsyncTask}
- to fetch and store them on the device for faster access.
- Never do network transactions on the application's UI thread.
- </li>
- <li>Scale down large images to a more appropriate size as you download them;
- otherwise, downloading the image itself may cause an out of memory exception.
- The following sample code demonstrates how to scale down images while downloading:
-<pre>
- // Get the source image's dimensions
- BitmapFactory.Options options = new BitmapFactory.Options();
- // This does not download the actual image, just downloads headers.
- options.inJustDecodeBounds = true;
- BitmapFactory.decodeFile(IMAGE_FILE_URL, options);
- // The actual width of the image.
- int srcWidth = options.outWidth;
- // The actual height of the image.
- int srcHeight = options.outHeight;
-
- // Only scale if the source is bigger than the width of the destination view.
- if(desiredWidth > srcWidth)
- desiredWidth = srcWidth;
-
- // Calculate the correct inSampleSize/scale value. This approach helps reduce
- // memory use. This value should be a power of 2.
- int inSampleSize = 1;
- while(srcWidth / 2 > desiredWidth){
- srcWidth /= 2;
- srcHeight /= 2;
- inSampleSize *= 2;
- }
-
- float desiredScale = (float) desiredWidth / srcWidth;
-
- // Decode with inSampleSize
- options.inJustDecodeBounds = false;
- options.inDither = false;
- options.inSampleSize = inSampleSize;
- options.inScaled = false;
- // Ensures the image stays as a 32-bit ARGB_8888 image.
- // This preserves image quality.
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-
- Bitmap sampledSrcBitmap = BitmapFactory.decodeFile(IMAGE_FILE_URL, options);
-
- // Resize
- Matrix matrix = new Matrix();
- matrix.postScale(desiredScale, desiredScale);
- Bitmap scaledBitmap = Bitmap.createBitmap(sampledSrcBitmap, 0, 0,
- sampledSrcBitmap.getWidth(), sampledSrcBitmap.getHeight(), matrix, true);
- sampledSrcBitmap = null;
-
- // Save
- FileOutputStream out = new FileOutputStream(LOCAL_PATH_TO_STORE_IMAGE);
- scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
- scaledBitmap = null;
-</pre>
- </li>
-</ul>
-
diff --git a/docs/html/preview/tv/ui/navigation.jd b/docs/html/preview/tv/ui/navigation.jd
deleted file mode 100644
index 684b743..0000000
--- a/docs/html/preview/tv/ui/navigation.jd
+++ /dev/null
@@ -1,136 +0,0 @@
-page.title=Navigation for TV
-
-@jd:body
-
-<div id="qv-wrapper">
-<div id="qv">
- <h2>In this document</h2>
- <ol>
- <li><a href="#d-pad-navigation">D-pad Navigation</a></li>
- <li><a href="#focus-selection">Focus and Selection</a></li>
- </ol>
-
-</div>
-</div>
-
-<p>TV devices provide a limited set of navigation controls for apps. Creating an effective
- navigation scheme for your TV app depends on understanding these limited controls and the limits
- of users' perception while operating your app. As you build your Android app for TVs,
- you should pay special attention to how the user actually navigates around your app
- when using remote control buttons instead of a touch screen.</p>
-
-<p>This guide shows you how to build an effective navigation scheme for your TV app.</p>
-
-
-<h2 id="d-pad-navigation">D-pad Navigation</h2>
-
-<p>On a TV device, users navigate with controls on a remote control device, using either a
- directional pad (D-pad) or arrow keys. This type of control limits movement to up, down, left,
- and right. To build a great TV-optimized app, you must provide a navigation scheme where
- the user can quickly learn how to navigate your app using these limited controls.</p>
-
-<p>Follow these guidelines to build a navigation system that works well with a D-pad on a TV device:
-</p>
-
-<ul>
- <li>Ensure that the D-pad can navigate to all the visible controls on the screen.</li>
- <li>For scrolling lists with focus, D-pad up/down keys scroll the list, and the Enter key selects
- an item in the list. Ensure that users can select an element in the list and that the list still
- scrolls when an element is selected.</li>
- <li>Ensure that movement between controls is straightforward and predictable.</li>
-</ul>
-
-<p>The Android framework handles directional navigation between layout elements automatically, so
- you typically do not need to do anything extra for your app. However, you should thoroughly test
- navigation with a D-pad control to discover any navigation problems. If you discover that your
- screen layout makes navigation difficult, or if you want users to move through the layout in a
- specific way, you can set up explicit directional navigation for your controls. The following
- code sample shows how to define the next control to receive focus for a
- {@link android.widget.TextView} layout object:</p>
-
-<pre>
-&lt;TextView android:id="&#64;+id/Category1"
- android:nextFocusDown="&#64;+id/Category2"\&gt;
-</pre>
-
-<p>The following table lists all of the available navigation attributes for Android user interface
-widgets:</p>
-
-<table>
- <tr>
- <th>Attribute</th>
- <th>Function</th>
- </tr>
- <tr>
- <td>{@link android.R.attr#nextFocusDown}</td>
- <td>Defines the next view to receive focus when the user navigates down.</td>
- </tr>
- <tr>
- <td>{@link android.R.attr#nextFocusLeft}</td>
- <td>Defines the next view to receive focus when the user navigates left.</td>
- </tr>
- <tr>
- <td>{@link android.R.attr#nextFocusRight}</td>
- <td>Defines the next view to receive focus when the user navigates right.</td>
- </tr>
- <tr>
- <td>{@link android.R.attr#nextFocusUp}</td>
- <td>Defines the next view to receive focus when the user navigates up.</td>
- </tr>
-</table>
-
-<p>To use one of these explicit navigation attributes, set the value to the ID ({@code android:id}
- value) of another widget in the layout. You should set up the navigation order as a loop, so that
- the last control directs focus back to the first one.</p>
-
-<p class="note">
- <strong>Note:</strong> You should only use these attributes to modify the navigation order if the
- default order that the system applies does not work well.
-</p>
-
-
-<h2 id="focus-selection">Focus and Selection</h2>
-
-<p>The success of a navigation scheme on TV devices is strongly dependent on how easy it is for a
- user to determine what user interface element is in focus on screen. If you do not provide clear
- indications of what is in focus on screen (and therefore what item they can take action on),
- users can quickly become frustrated and exit your app. By the same token, it is important
- to always have an item in focus that a user can take action on immediately after your app starts,
- and any time your app is not playing content.</p>
-
-<p>Your app layout and implementation should use color, size, animation, or a combination of
- these attributes to help users easily determine what actions they can take next. Use a uniform
- scheme for indicating focus across your application.</p>
-
-<p>Android provides <a href="{@docRoot}guide/topics/resources/drawable-resource.html#StateList">
-Drawable State List Resources</a> to implement highlights for selected and focused controls. The
-following code example demonstrates how to indicate selection of a button object:
-</p>
-
-<pre>
-&lt;!-- res/drawable/button.xml --&gt;
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
- &lt;item android:state_pressed="true"
- android:drawable="@drawable/button_pressed" /&gt; &lt;!-- pressed --&gt;
- &lt;item android:state_focused="true"
- android:drawable="@drawable/button_focused" /&gt; &lt;!-- focused --&gt;
- &lt;item android:state_hovered="true"
- android:drawable="@drawable/button_focused" /&gt; &lt;!-- hovered --&gt;
- &lt;item android:drawable="@drawable/button_normal" /&gt; &lt;!-- default --&gt;
-&lt;/selector&gt;
-</pre>
-
-<p>
-This layout XML applies the above state list drawable to a {@link android.widget.Button}:
-</p>
-<pre>
-&lt;Button
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:background="@drawable/button" /&gt;
-</pre>
-
-<p>Make sure to provide sufficient padding within the focusable and selectable controls so that
- the highlights around them are clearly visible.</p>
-