I've implemented a ListView
with CardView
s inside following some online tutorials.
Fragment of layout containing the list
<ListView
android:id="@+id/interactions_list"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:visibility="invisible"
android:layout_alignParentTop="true"
android:divider="#000000"
android:dividerHeight="4dp"
/>
Element layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical"
>
<android.support.v7.widget.CardView
android:background="#00000000"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_margin="5dp"
card_view:cardCornerRadius="2dp"
card_view:contentPadding="10dp"
android:id="@+id/cv">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dip">
<TableRow android:padding="5dip">
<ImageView
android:id="@+id/pkicon"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="3dp"/>
<LinearLayout android:id="@+id/lnlayout"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_margin="3dip">
<TextView
android:id="@+id/pkname"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:textColor="#000000"
android:textSize="20sp"/>
<TextView
android:id="@+id/pknot"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:textColor="#606060"/>
</LinearLayout>
</TableRow>
</TableLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
Now I am encountering strange behavior when user taps a card, as seen on this screenshot:
The card is shown correctly, but when tapped, the ripple effect covers the LinearLayout
element and the card has a solid opaque background.
Expected behavior: the background behind the card remains white, the ripple effect occurs only on the card.
Please help out.