I\'m using card view for floating action button in android material design. I\'m using following code for get the circle
<androidx.cardview.widget.CardView
android:layout_width="60dp"
android:layout_marginStart="150dp"
app:cardCornerRadius="360dp"
android:layout_height="60dp">
Yes, I have achieved it by reducing half of the CardCornerRadius to its View's Height.
I tried your code and found out that the Cards were less round with respect to the increase in the card elevation value.Try setting it to zero and this at least makes it look better.
card_view:cardElevation="0dp";
But a probably better option would be to use the FloatingActionButton
for the round button
<android.support.design.widget.FloatingActionButton
android:src="@drawable/your_drawble_name"
app:fabSize="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Using CardView to obtain circular background with shadow can be quiet troublesome intead use layer-list in drawable to get the desired output.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<!--shadow color you want-->
<solid android:color="#C3C1C1"/>
</shape>
</item>
<item
android:left="0dp"
android:right="0dp"
android:top="0dp"
android:bottom="2dp">
<shape android:shape="oval">
<solid android:color="@color/white"/>
</shape>
</item>
</layer-list>
I came up with simple Solution of Using a Drawable and it looks amazing!
Get Drawable here https://drive.google.com/open?id=0B4Vo_ku-aIKzUFFnUjYxYVRLaGc
To get a perfect circle shape using a card view, corner radius should be 1/2 of width or height (taking into consideration that it is a square). also, I have noticed that you are using card_view params, don't.
<android.support.v7.widget.CardView
android:layout_width="38dp"
android:layout_height="38dp"
app:cardCornerRadius="19dp"
app:cardElevation="6dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:id="@+id/fab"
android:background="@color/blue"
>