简体   繁体   中英

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:

在此处输入图片说明

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.

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"/>

PS - The same applies for the top.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM