Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get(reference) the current theme default text color in XML
    primarykey
    data
    text
    <p>I have a shape (<i>rect_shape.xml</i>) which draws a stroke outline in every item of a listview (<i>listview_style.xml</i>). This outline should have the same color like the default text color of the current theme.</p> <p>Is there any way, <strong>in XML</strong>, to set the android:color value of the stroke to the current text color?</p> <p>I've seen some similar questions (like <a href="https://stackoverflow.com/questions/8271329/how-to-get-my-own-defined-attribute-value-in-my-style">How to get my own defined attribute value in my style</a> ) around here which try to set an own attribute, but I don't think that this is what I want. Anyhow I tried that but I couldn't set the android:color value to my own defined attribute ( <code>android:color="?custom_stroke_color"</code> throws InflateException).</p> <p>Because the user is able to switch between the Themes dynamically, one single predefined color (or reference to a color resource e.g. <code>@color/white</code> ) in <i>rect_shape.xml</i> is not an option.</p> <p>Appreciate any help...</p> <p><strong>rect_shape.xml</strong></p> <pre><code>&lt;shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" &gt; &lt;stroke android:width="3dp" &lt;!-- should be the current default text color --&gt; android:color="#FFF" /&gt; &lt;solid/&gt; ... &lt;/shape&gt; </code></pre> <p><strong>listview_style.xml</strong></p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/rect_shape" &gt; ... &lt;/LinearLayout&gt; </code></pre> <p><strong>themes.xml</strong></p> <pre><code>&lt;resources&gt; &lt;style name="DarkTheme" parent="@style/Theme.Sherlock"&gt; &lt;!-- default text color is white --&gt; ... &lt;/style&gt; &lt;style name="LightTheme" parent="@style/Theme.Sherlock.Light"&gt; &lt;!-- default text color is black--&gt; ... &lt;/style&gt; &lt;/resources&gt; </code></pre>
    singulars
    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.
 

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