2

Consider the below code:

layout file:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffff00"
    >

    <TextView
        android:id="@+id/a"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:background="@drawable/onboarding_button_banner"
        android:elevation="4dp"
        />

</FrameLayout>

@drawable/onboarding_button_banner:

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    >
    <solid android:color="#ffffff" />
    <corners android:radius="1dp" />
</shape>

This gives output:

enter image description here But removing the corner radius from drawable removes the shadow for elevation: keeping everything else same.

enter image description here

Gursimran Singh
  • 301
  • 2
  • 5

0 Answers0