Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are currently up to 3, sometimes 4 Themes available for Android devices (<code>.Light</code> variations and similar not included)</p> <h3><code>Theme</code></h3> <blockquote> <p><img src="https://i.stack.imgur.com/RUQQu.png" alt="Theme"></p> </blockquote> <p>the default for the earliest versions of Android up to 2.3 Gingerbread(10), including some minor style changes in those versions</p> <hr> <h3><code>Theme.Holo</code></h3> <blockquote> <p><img src="https://i.stack.imgur.com/mLlLv.png" alt="Theme.Holo"></p> </blockquote> <p>introduced with Android 3.0 Honeycomb (11)</p> <hr> <h3><code>Theme.Material</code></h3> <blockquote> <p><img src="https://i.stack.imgur.com/h6pmZ.png" alt="Theme.Material"></p> </blockquote> <p>new in Android 5.0 Lollipop (21)</p> <hr> <h3><code>Theme.DeviceDefault</code></h3> <blockquote> <p>(Could be anything)</p> </blockquote> <p>introduced with 4.0 Ice Cream Sandwich (14), a theme that can be customized by the device manufacturer. It represents the native look of the device - i.e. Holo or Material on Nexus devices (&amp; in Android Studio's design editor), maybe something custom on other devices. In case "something custom" isn't an option, those devices must come with the stock themes. Apps that want the stock theme have to specify it though.</p> <hr> <blockquote> <p>What is the best approach to this?</p> </blockquote> <h3>No theme + targetSdkVersion >= 14</h3> <p>The simplest, but not necessarily best option is to define no theme at all. Android will then select the default for you. But Android does not want to surprise your app with themes you're not expecting so it falls back to the Theme you probably had designed your app for. It does so by looking at the <code>android:targetSdkVersion</code> within <code>AndroidManifest.xml</code> (which can nowadays be set via gradle).</p> <ul> <li>Apps that target old platforms, which had only <code>Theme</code> (i.e. API levels 3-10), will get only <code>Theme</code>.</li> <li>Apps targeting 11-13 get <code>Theme.Holo</code>.</li> <li>14 or above will get <code>Theme.DeviceDefault</code>.</li> </ul> <p>Since this is just for backwards compatibility, you won't get <code>Theme.Material</code> on your old Gingerbread phone. Therefore no theme + target 14+ = device default.</p> <h3>Specifying different themes</h3> <p>Android's resource overlay system allows to specify styles based on device API level. For example different versions of a style in <code>res/values-v11</code> and <code>res/values-v21</code>. This is also what any newly created apps via Android Studio will setup for you.</p> <p>As an example, the most basic setup for a <code>.Light</code> themed app looks like this:</p> <p><code>/res/values/styles.xml</code> is applied to every device and serves as base</p> <pre><code>&lt;resources&gt; &lt;style name="AppTheme" parent="android:Theme.Light"/&gt; &lt;/resources&gt; </code></pre> <hr> <p><code>/res/values-v11/styles.xml</code> is loaded on all devices that have API level 11 and above (including those that are 21 and above). But just the newest version of "AppTheme" is actually used.</p> <pre><code>&lt;resources&gt; &lt;style name="AppTheme" parent="android:Theme.Holo.Light"/&gt; &lt;/resources&gt; </code></pre> <hr> <p><code>/res/values-v21/styles.xml</code> </p> <pre><code>&lt;resources&gt; &lt;style name="AppTheme" parent="android:Theme.Material.Light"/&gt; &lt;/resources&gt; </code></pre> <p>Note: alternatively specifying <code>Theme.DeviceDefault</code> in <code>/res/values-v14/styles.xml</code> should be enough for having a default look but that doesn't allow to fine tune the design. Doesn't hurt to add the v14 override. DeviceDefault and Holo could be different after all.</p> <hr> <p><code>AndroidManifest.xml</code> is the place where the custom theme is put to use. E.g. as application wide default:</p> <pre><code>... &lt;application android:theme="@style/AppTheme" ... </code></pre> <hr> <h3>Links to official documentation</h3> <p><a href="http://developer.android.com/guide/topics/ui/themes.html#SelectATheme" rel="noreferrer">Select a theme based on platform version</a> - Official doc for defining different styles via resource configurations</p> <p><a href="http://android-developers.blogspot.de/2012/01/holo-everywhere.html" rel="noreferrer">Holo Everywhere</a> - blog post that explains the default mechanism and DeviceDefault / Holo theme</p> <p><a href="https://developer.android.com/training/material/theme.html" rel="noreferrer">Using the Material Theme</a> - material documentation</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload