Invalid Android item not working

Since upgrading to SDK 21, I have been trying to use the elevation property, but it never works.

I want to raise the frame above the others, so I set the following

android:elevation="4dp" 

but no shadow. I tried buttons and frames but got no value.

So the full tag

  <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/panel_card" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ffffff" android:elevation="4dp" > 

I missed something else I need to add

+6
source share
3 answers

According to this Z = Elevation + TranslationZ

try the following:

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/panel_card" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ffffff" android:elevation="4dp" android:translationZ="4dp"> 
+2
source

Make sure the background for the container containing FrameLayout is not transparent.

+23
source

@Tinashe answer is correct, but instead of using

 android:elevation="4dp" 

using:

 card_view:elevation="4dp" 
-1
source

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


All Articles