4

If I use this on my card view as foreground, application will crash on pre API 10.

    <android.support.v7.widget.CardView
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:layout_margin="@dimen/card_margin"
 //android:foreground="?android:attr/selectableItemBackground"
    android:elevation="3dp"
    card_view:cardCornerRadius="@dimen/card_album_radius">

I'm working on a project about seven months and my app worked on every API level until now.. this is forcing me to raise my min SDK.

Can you please help me with this, how can I bypass it.


temporary answer

I'm using this

android:foreground="?attr/selectableItemBackground"

insteat of:

android:foreground="?android:attr/selectableItemBackground"

It's some kind of gray color onClick instead of blue, but I do not care much about the color, So this will solve the crashing problem for now

Community
  • 1
  • 1
DastakWall
  • 377
  • 1
  • 7
  • 25

1 Answers1

0

User android:foreground="?selectableItemBackgroundBorderless" instead of android:foreground="?android:attr/selectableItemBackground"

Using ?attr: (or the ? shorthand) instead of ?android:attr references the support library, so is available back to API 7.

Anand Singh
  • 1,091
  • 13
  • 21