Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set a different theme to a Layout
    primarykey
    data
    text
    <p>I've set a default theme for the whole app. It's defined in styles.xml as follows:</p> <pre><code> &lt;style name="DefaultTheme" parent="@android:style/Theme.Holo.Light"&gt; &lt;!-- Customization here --&gt; &lt;/style&gt; </code></pre> <p>I've also defined a dark theme:</p> <pre><code> &lt;style name="DarkTheme" parent="@android:style/Theme.Holo"&gt; &lt;!-- Customization here --&gt; &lt;/style&gt; </code></pre> <p>In the manifest it is declared the light theme as the main theme for the app:</p> <pre><code> &lt;application ... android:theme="@style/DefaultTheme" &gt; </code></pre> <p>Now this is working fine, but in an activity, I need to set a different theme for a single Layout. Something like this:</p> <pre><code> +--------------------------------------------------+ | Parent Linear layout (default theme) | | | | +------------------------------------+ +-------+ | | | | | | | | | Left linear layout | | | | | | (default theme) | | | | | | | | | | | | | | | | | | | | ·&lt;----------- Right Linear Layout | | | | | | (Need it in dark theme) | | | | | | | | | | | | | +------------------------------------+ +-------+ | +--------------------------------------------------+ </code></pre> <p>In the layout xml file I'm trying to set a theme for the rightmost child LinearLayout:</p> <pre><code> &lt;LinearLayout style="@style/DarkTheme"&gt; ... </code></pre> <p>I'd expect this to work just fine, and to apply the dark theme to the right layout only (and its child views), but it is not working. I've tried replacing the @style with a built-in @android:style to no avail. I've tested this in the layout editor and on real device/simulator.</p> <p>Is it possible to apply a custom theme or style to a single layout?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    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