Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try to set <code>android:focusable</code> and <code>android:focusableInTouchMode</code> to <code>false</code> to your button:</p> <pre><code>&lt;Button android:id="@+id/btn_like" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" android:focusable="false" android:focusableInTouchMode="false" /&gt; </code></pre> <p><strong>UPDATE</strong> You need to set your <code>Button</code> <code>android:focusable</code> as <code>false</code> and also the <code>RelativeLayout</code>. Plus, you need to have a <code>selector</code> for your both <code>Button</code> and <code>RelativeLayout</code> Here:</p> <pre><code>&lt;Button android:id="@+id/btn_like" android:layout_width="wrap_content" android:layout_height="wrap_content" android:focusable="false" android:background="@drawable/selector"/&gt; </code></pre> <p>And Here:</p> <pre><code>&lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp" android:background="@drawable/selector_translate_blue" android:background="@drawable/selector_ll" android:focusable="false" &gt; </code></pre> <p>And here is the important thing, in those <code>selector</code>s, at the <code>android:state_pressed</code>, you need to add more the <code>android:state_focused</code>, this way, when the item click, the <code>Button</code> and <code>RelativeLayout</code> can NOT get <code>focusable</code>, so it will NOT trigger this state:</p> <p>selector.xml:</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:drawable="@android:color/darker_gray" android:state_pressed="true" android:state_focused="true"&gt;&lt;/item&gt; &lt;/selector&gt; </code></pre> <p>selector_ll.xml:</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:state_focused="true" android:drawable="@android:color/darker_gray"/&gt; &lt;!-- pressed --&gt; &lt;item android:state_focused="true" android:drawable="@android:color/darker_gray"/&gt; &lt;!-- focused --&gt; &lt;item android:drawable="@android:color/white"/&gt; &lt;!-- default --&gt; &lt;/selector&gt; </code></pre> <p>Hope this helps.</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.
 

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