I'm trying to give an elevation in the corners of the map

I try to provide elevationin the corners cardview. my demand elevationshould not affect the middle cardview. it should only act on corners, as shown in the figure below.

As shown in the figure, in the middle cardview elevationmust be zero at the corners, must have some elevation(eg elevation:4dp)

Here is the code I've tried so far

 <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:layout_width="match_parent"
                                            android:layout_height="wrap_content"
                                            android:layout_marginLeft="10dp"
                                            android:layout_marginRight="10dp"
                                            android:layout_marginTop="10dp"
                                            android:background="@null"
                                            android:gravity="center"
                                            card_view:cardBackgroundColor="@android:color/white"
                                            card_view:cardCornerRadius="4dp"
                                            card_view:cardElevation="3dp">
+4
source share
1 answer

Try to install card_view:cardUseCompatPadding="true"

So your xml should look like this:

<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:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:background="@null"
            android:gravity="center"
            card_view:cardBackgroundColor="@android:color/white"
            card_view:cardUseCompatPadding="true"
            card_view:cardCornerRadius="4dp"
            card_view:cardElevation="3dp"/>
+1
source

Source: https://habr.com/ru/post/1685678/


All Articles