Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This can be achieved by creating a drawable xml file containing a list of states for the button. So for example if you create a new xml file called "button.xml" with the following code:</p> <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/YOURIMAGE" /&gt; &lt;item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/gradient" /&gt; &lt;item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/gradient" /&gt; &lt;item android:drawable="@drawable/YOURIMAGE" /&gt; &lt;/selector&gt; </code></pre> <p>To keep the background image with a darkened appearance on press, create a second xml file and call it gradient.xml with the following code:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;item&gt; &lt;bitmap android:src="@drawable/YOURIMAGE"/&gt; &lt;/item&gt; &lt;item&gt; &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;gradient android:angle="90" android:startColor="#880f0f10" android:centerColor="#880d0d0f" android:endColor="#885d5d5e"/&gt; &lt;/shape&gt; &lt;/item&gt; &lt;/layer-list&gt; </code></pre> <p>In the xml of your button set the background to be the button xml e.g.</p> <pre><code>android:background="@drawable/button" </code></pre> <p>Hope this helps!</p> <p>Edit: Changed the above code to show an image (YOURIMAGE) in the button as opposed to a block colour.</p>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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