Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get my own defined attribute value in my style
    primarykey
    data
    text
    <p>I want to create 3 different themes for a dialog using a custom (own) attribute. I would like to set title colors by adding this to theme's style: <code>&lt;item name="titleColor"&gt;#FF0000&lt;/item&gt;</code></p> <p>my themes.xml: </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;style name="MyTheme" parent="@android:style/Theme"&gt; &lt;item name="android:alertDialogStyle"&gt;@style/dialog&lt;/item&gt; &lt;/style&gt; &lt;style name="MyRedTheme" parent="MyTheme"&gt; &lt;item name="titleColor"&gt;#FF0000&lt;/item&gt; &lt;/style&gt; &lt;style name="MyGreenTheme" parent="MyTheme"&gt; &lt;item name="titleColor"&gt;#00FF00&lt;/item&gt; &lt;/style&gt; &lt;style name="MyBlueTheme" parent="MyTheme"&gt; &lt;item name="titleColor"&gt;#0000FF&lt;/item&gt; &lt;/style&gt; </code></pre> <p></p> <p>I defined titleColor attribute in attrs.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;declare-styleable name="MyCustomAttributes"&gt; &lt;attr name="titleColor" format="color|reference" /&gt; &lt;/declare-styleable&gt; &lt;/resources&gt; </code></pre> <p>I apply one of the themes for the dialog. How can I pass my titleColor attribute's value to an "android:color" attribute?</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;shape xmlns:android="http://schemas.android.com/apk/res/android" xmlns:custom="http://schemas.android.com/apk/res/com.dicare" android:shape="rectangle"&gt; &lt;solid android:color="I want to pass titleColor value here"/&gt; &lt;/shape&gt; </code></pre>
    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.
 

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