Elevation not working on a LinearLayout

As described here https://stackoverflow.com/a/27518160/2481494 there are several requirements so that the shadow is drawn:

  • Space for the shadow in the parents view Group. As bleeding182 mentioned, padding can cause the shadow to be clipped:

    (Do NOT use a padding. A padding on the framelayout will also cut the shadow off)

    However, this can be fixed with android:clipToPadding="false" in the parent.

  • The elevated view needs to have a background to cast a shadow. Without information about your @drawable/button_flat_white I can’t tell whether this is a problem in your case.

To solve your problem you should modify your FrameLayout like this:

<FrameLayout
        android:id="@+id/fragment_container_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"

        android:clipToPadding="false"
        android:paddingBottom="10dp"/>

To check whether your @drawable/button_flat_white causes any problems try to change the background of your LinearLayout to a simple color temporarily:

<LinearLayout
    android:id="@+id/panelAddress"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="10dp"
    android:orientation="vertical"
    android:padding="20dp"

    android:background="#fff">  
//some content
</LinearLayout>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)