Theme not applied on custom view (Android)
<p>I'm making a view which I'm going to use as a background for various other views. It could contain a TextView, a Button, a LinearLayout etc.</p>

<p>Based on the selected theme (the app allows you to change themes while running) the background image of this view should be different. However, nothing seems to happen. The background is not set. It works on a "native" View (like TextView or Button)</p>

<p>View (note: I've played around and changed super class a few times in order to get it working):</p>

<pre><code>public class HorizontalContainerBar extends TextView
{
    public HorizontalContainerBar(Context context)
    {
        super(context);
    }

    public HorizontalContainerBar(Context context, AttributeSet attrs)
    {
        super(context, attrs);
    }

    public HorizontalContainerBar(Context context, AttributeSet attrs, int defStyle)
    {
        super(context, attrs, defStyle);
    }
}
</code></pre>

<p>This is part of themes.xml:</p>

<pre><code>&lt;style name="Theme" parent="android:style/Theme"&gt;`
        &lt;item name="android:windowTitleSize"&gt;20dip&lt;/item&gt;
        &lt;item name="horizontalContainerBarStyle"&gt;@style/horizontal_container_bar_first&lt;/item&gt;
&lt;/style&gt;
&lt;style name="Theme.First"&gt;
        &lt;item name="horizontalContainerBarStyle"&gt;@style/horizontal_container_bar_first&lt;/item&gt;
&lt;/style&gt;
</code></pre>

<p>This is part of styles.xml:</p>

<pre><code>&lt;style name="horizontal_container_bar" parent="@android:style/Widget.Button"&gt;
    &lt;item name="android:padding"&gt;10dp&lt;/item&gt;
    &lt;item name="android:textColor"&gt;#ffffff&lt;/item&gt;
    &lt;item name="android:gravity"&gt;center_vertical|left&lt;/item&gt;
&lt;/style&gt;

&lt;style name="horizontal_container_bar_first" parent="@style/horizontal_container_bar"&gt;
    &lt;item name="android:background"&gt;@drawable/panel_first&lt;/item&gt;
&lt;/style&gt;
</code></pre>

<p>This is a part of the attrs.xml:</p>

<pre><code>&lt;attr name="horizontalContainerBarStyle" format="reference"/&gt;
</code></pre>

<p>(not inside a declare-stylable tag - but it used to be)</p>

<p>This is inside my layout file:</p>

<pre><code>&lt;com.myapp.views.HorizontalContainerBar android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:text="hello"&gt;
&lt;/com.myapp.views.HorizontalContainerBar&gt;
</code></pre>

<p>Does anyone have any idea what I'm doing wrong here?</p>
