Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting padding of a shape resource / GradientDrawable in code
    primarykey
    data
    text
    <p>I have an xml file with a selector in it that defines the different states for a button:</p> <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_pressed="true" android:drawable="@drawable/custom_green_button_selected_state" /&gt; &lt;item android:state_enabled="false" android:drawable="@drawable/custom_green_button_disabled_state" /&gt; &lt;item android:drawable="@drawable/custom_green_button_normal_state"/&gt; &lt;/selector&gt; </code></pre> <p>Then in each of my drawable xmls I have information on how the button looks like this:</p> <pre><code>&lt;shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"&gt; &lt;gradient android:type="linear" android:gradientRadius="180" android:startColor="#6b9f41" android:endColor="#598a3d" /&gt; &lt;corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" android:topLeftRadius="7dp" android:topRightRadius="7dp" /&gt; &lt;padding android:left="15dp" android:right="15dp" android:top="10dp" android:bottom="10dp" /&gt; &lt;/shape&gt; </code></pre> <p>For most of the buttons in my app I just apply the first xml as the background and everything works fine. For a specific button, I'd like to use the same xmls but make the button skinnier by changing the padding of the drawables. I thought I'd try creating a new StateListDrawable in my code and adding a mutate of each of the individual state's drawable xmls, however, these drawables show up as GradientDrawables which doesn't seem to give me access to their padding properties. Any ideas?</p>
    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