In the latest Android SDK we now have the new CardView, I have replaced my old CustomCardView with the new version, but when running with this on older versions of Android I see that the state_pressed
& state_focused
are ugly squares which show up above the CardView...
does anyone know how I could emulate the following in the new CardView but only when using older versions of Android?
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:enterFadeDuration="150"
android:exitFadeDuration="150" >
<item android:state_pressed="true"
android:drawable="@drawable/card_on_press"/>
<item android:state_focused="true" android:state_enabled="true"
android:drawable="@drawable/card_on_focus"/>
<item android:state_enabled="true"
android:drawable="@drawable/card_default"/>
<item android:state_enabled="false"
android:drawable="@drawable/card_on_press"/>
</selector>
And for those of you interested here is the CardView that I am using now:
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:foreground="?android:attr/selectableItemBackground"
android:onClick="RunSomeMethod"
card_view:cardCornerRadius="4dp"
android:focusable="true"
android:elevation="2dp">
<LinearLayout
android:id="@+id/LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="false"
android:visibility="visible">
</LinearLayout>
</android.support.v7.widget.CardView>