jamesxbrown
jamesxbrown

Reputation: 135

View doesn't show shadow on the bottom

It's a simple view in a FrameLayout. I need the FrameLayout for other views later. The code for the view:

<View
  android:layout_width="match_parent"
  android:background="@drawable/nav_style_start"
  android:layout_height="100dp"
  android:layout_marginStart="15dp"
  android:layout_marginEnd="15dp"
  android:elevation="2dp"/>

The line @drawable/nav_style_start is necessary to add cornerRadius. The result:

enter image description here

Look at the bottom of the view, I can't see the full shadow. I've no idea why this happening, it's really weird.

Upvotes: 0

Views: 38

Answers (2)

Naitik Soni
Naitik Soni

Reputation: 770

Replace android:elevation="2dp" with app:elevation="2dp"

It will work. and try with > 4dp for clear visible shadow.

Upvotes: 0

Chrisvin Jem
Chrisvin Jem

Reputation: 4060

The View is getting clipped in the bottom. Just add a bit of margin to the bottom to make it visible.

<View
  android:layout_width="match_parent"
  android:background="@drawable/nav_style_start"
  android:layout_height="100dp"
  android:layout_marginStart="15dp"
  android:layout_marginBottom="15dp"
  android:layout_marginEnd="15dp"
  android:elevation="2dp"/>

P.S - The same applies for the top.

Upvotes: 1

Related Questions