blob: b4d26a769cf4b0c927b09c3a5693e141f928f770 [file] [log] [blame]
page.title=Compatibility
@jd:body
<div id="qv-wrapper">
<div id="qv">
<h2>In this document</h2>
<ol>
<li><a href="#materialtheme">Material Theme</a></li>
<li><a href="#layouts">Layouts</a></li>
<li><a href="#widgets">UI Widgets</a></li>
<li><a href="#animation">Animation APIs</a></li>
</ol>
</div>
</div>
<p>The new material design features (like the material theme and activity transitions) are only
available in the Android L Developer Preview. However, you can design your apps to make use of
these features when running on devices with the Android L Developer Preview and still be
compatible with previous releases of Android.</p>
<h2 id="materialtheme">Material Theme</h2>
<p>The material theme is only available in the Android L Developer Preview. To configure your
app to use the material theme on devices running the Android L Developer Preview and an older
theme on devices running earlier versions of Android:</p>
<ol>
<li>Define a theme that inherits from an older theme (like Holo) in
<code>res/values/styles.xml</code>.</li>
<li>Define a theme with the same name that inherits from the material theme in
<code>res/values-v21/styles.xml</code>.</li>
<li>Set this theme as your app's theme in the manifest file.</li>
</ol>
<p class="note"><strong>Note:</strong> If you do not provide an alternative theme in this manner,
your app will not run on earlier versions of Android.</p>
<h2 id="layouts">Layouts</h2>
<p>If the layouts that you design according to the material design guidelines do not use any
of the new XML attributes from the Android L Developer Preview, they will work on previous
versions of Android. Otherwise, you can provide alternative layouts. You can also provide
alternative layouts to customize how your app looks on earlier versions of Android.</p>
<p>Create your layout files for the Android L Developer Preview inside <code>res/layout-v21/</code>
and your alternative layout files for earlier versions of Android inside <code>res/layout/</code>.
Alternative layouts have the same file name.</p>
<p>To avoid duplication of code, define your styles inside <code>res/values/</code> and modify the
styles in <code>res/values-v21/</code> for the new APIs.</p>
<h2 id="widgets">UI Widgets</h2>
<p>The <code>RecyclerView</code> and <code>CardView</code> widgets are included in the Android L
Developer Preview Support Library, so they are available in earlier versions of Android with
these limitations:</p>
<ul>
<li><code>CardView</code> falls back to a programmatic shadow implementation using additional padding.</li>
<li><code>CardView</code> does not clip its children views that intersect with rounded corners.</li>
</ul>
<p>These limitations do not apply to the Android L Developer Preview.</p>
<h2 id="animation">Animation APIs</h2>
<p>The following new APIs are only available in the Android L Developer Preview:</p>
<ul>
<li>Activity transitions</li>
<li>Touch feedback</li>
<li>Reveal animations</li>
<li>Path-based animations</li>
</ul>
<p>To preserve compatibility with earlier versions of Android, check the system version at
runtime before you invoke these APIs.</p>