Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to fix CardView Corner radius issue?

I'm using below code to create a CardView with corners but it stay rectangular

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/cardview_id"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:clickable="true"
    android:focusable="true"
    android:foreground="?android:attr/selectableItemBackground"
    card_view:cardCornerRadius="6dp">

UPDATE : there was a mistake in my Manifest i just remove this line:

android:hardwareAccelerated="false"

like image 399
KOTL NIAS Avatar asked Oct 25 '18 13:10

KOTL NIAS


Video Answer


2 Answers

I also had same issue. The issue I found is...

        android:hardwareAccelerated="false"

removed this line from manifests and the issue resolved for me.

like image 70
Somen Tushir Avatar answered Oct 05 '22 03:10

Somen Tushir


I saw nothing wrong with your code, but if it couldn't worked. try to add this:

    app:cardCornerRadius="@dimen/margin_small"
    app:cardElevation="@dimen/margin_small"
    app:cardUseCompatPadding="true"

It worked well for me. And make sure you're runing above API 21.

like image 37
Stevie Avatar answered Oct 05 '22 02:10

Stevie