Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I tested your code (<em>the XML as well as the Java</em>) in a quick test project. It crashes all right. Apparently, the layout does not like <code>android:background</code> attribute set in it.</p> <p>Removing this line from the parent RelativeLayout will fix it:</p> <pre><code>android:background="@style/AppBaseTheme" </code></pre> <p>Testing on my device:</p> <p><img src="https://i.stack.imgur.com/Ng5so.png" alt="enter image description here"></p> <p>The final parent <code>RelativeLayout</code> will look this this:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/rel" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" &gt; .... .... &lt;/RelativeLayout&gt; </code></pre> <p>As to why it does not like that attribute is because it maps to a style in the <code>styles.xml</code> called: <code>AppBaseTheme</code>. If you have created the project using the <em>Android Application Project</em> wizard, as I did, I have noticed it creates a <em>blank</em> styles.xml with just this in it:</p> <pre><code>&lt;resources&gt; &lt;!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --&gt; &lt;style name="AppBaseTheme" parent="android:Theme.Light"&gt; &lt;!-- Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to backward-compatibility can go here. --&gt; &lt;/style&gt; &lt;!-- Application theme. --&gt; &lt;style name="AppTheme" parent="AppBaseTheme"&gt; &lt;!-- All customizations that are NOT specific to a particular API-level can go here. --&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <p>Naturally, the attribute <code>android:background="@style/AppBaseTheme"</code> does not have the necessary that will supply the <code>RelativeLayout</code> with a resource that is compatible with the <code>android:background</code> attribute.</p>
 

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