Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extending cardview class show white rectangle around the card

I'm extending CardView class because I want to create custom view for each row of my list view. this is my xml layout

<com.mojiapps.myquran.items.TranslationDownloadItemView  xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="?selectableItemBackground"
android:gravity="right"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="3dp"
card_view:cardPreventCornerOverlap="false">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">
...

</com.mojiapps.myquran.items.TranslationDownloadItemView>

and this is my java class

public class TranslationDownloadItemView extends CardView {


public TranslationDownloadItemView(Context context) {
    super(context);
    init();
}

public TranslationDownloadItemView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

private void init() {
    LayoutInflater inflater = LayoutInflater.from(getContext());

    inflater.inflate(R.layout.translation_type_row, this);
...
}
...
}

and this is the result

enter image description here

can anybody help me?

like image 733
Mojtaba Mahamed Avatar asked Jul 05 '15 20:07

Mojtaba Mahamed


1 Answers

I had this issue setting the CardView background to something transparent. I solved it setting a non-alpha color.

Try to set your android:foreground to something without alphas.

like image 92
Javier Delgado Avatar answered Oct 12 '22 23:10

Javier Delgado