Note that there are some explanatory texts on larger screens.

plurals
  1. POImageButton using Transitions in Android
    primarykey
    data
    text
    <p>I'm trying to create a transparent (no button background) ImageButton that has a custom selector. I have the selector working against the button but I now want the selector drawables to cross-fade into each other. I saw the TransitionDrawable object that can be represented in XML. Is there a way to connect this into my selector?</p> <p>Below is the XML layout code to create the image button on the screen in the lower left corner of the screen. It currently goes from one image to the next abruptly ignoring the transition XML.</p> <p><strong>selector_button.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_pressed="true" android:drawable="@drawable/transition_normal_to_pressed" /&gt; &lt;!-- pressed --&gt; &lt;item android:state_focused="true" android:drawable="@drawable/transition_pressed_to_normal" /&gt; &lt;!-- focused --&gt; &lt;item android:drawable="@drawable/menu_normal" /&gt; &lt;!-- default --&gt; &lt;/selector&gt; </code></pre> <p><strong>transition_normal_to_pressed.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;transition xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:drawable="@drawable/menu_pressed" /&gt; &lt;item android:drawable="@drawable/menu_normal" /&gt; &lt;/transition&gt; </code></pre> <p><strong>activity.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ImageButton android:id="@+id/btnMenu" android:background="@android:color/transparent" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/selector_button" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" /&gt; &lt;/RelativeLayout&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