Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found a solution, I don't know if it's the best solution, but it got what I wanted done.</p> <p>Put simply, I've found that adding the selector code inside the card_layout.xml file does not work. What you should do is create a layout xml file for each state that you wish to implement on the button or list item and embed that layout in the selector itself, like in the answer for this SO post here: <a href="https://stackoverflow.com/questions/8339529/android-using-layer-list-for-button-selector">Android Using layer-list for button selector.</a></p> <p>Since I didn't want to bother finding out colors and transparencies I would need to implement the background for three different states I've basically placed a RelativeLayout which lies over top of the entire list item to act as the select-able part of the item.</p> <p>The code for this is here:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="72dp"&gt; &lt;RelativeLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="5dp" android:layout_marginBottom="5dp" android:background="@drawable/card_layout"&gt; &lt;LinearLayout android:id="@+id/linearLayout_thumbnail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center_vertical"&gt; &lt;ImageView android:layout_width="50dp" android:layout_height="50dp" android:id="@+id/imageView_thumbnail"/&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="50dp" android:orientation="vertical" android:layout_toRightOf="@+id/linearLayout_thumbnail" android:gravity="center_vertical"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView_title" android:paddingLeft="5dp" android:textSize="18dp" android:text="SOME TEXT" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView_subtitle" android:paddingLeft="5dp" android:textSize="12dp" android:text="SOME TEXT" /&gt; &lt;/LinearLayout&gt; &lt;TextView android:id="@+id/textView_extra" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="12dp" android:layout_alignParentRight="true" android:layout_centerVertical="true"/&gt; &lt;/RelativeLayout&gt; &lt;RelativeLayout android:layout_height="match_parent" android:layout_width="match_parent" android:background="@drawable/list_item_selector" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="5dp" android:layout_marginBottom="5dp"/&gt; &lt;/FrameLayout&gt; </code></pre> <p>So, now this is working, screenshot here: <img src="https://i.stack.imgur.com/2pelj.png" alt="Proper item selection."></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. 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