Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elevation shadow missing #35

Closed
habim84 opened this issue Dec 28, 2018 · 2 comments
Closed

Elevation shadow missing #35

habim84 opened this issue Dec 28, 2018 · 2 comments

Comments

@habim84
Copy link

habim84 commented Dec 28, 2018

I've enclosed my linear layout with a maskable layout to mask the rounded edges. Within said linear layout contains a recycler view that has an item view with its elevation attribute set. Somehow, the shadows disappeared when I enclosed this linear layout within the maskable layout.

<com.christophesmet.android.views.maskableframelayout.MaskableFrameLayout
            android:id="@+id/frm_mask_animated"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            app:porterduffxfermode="DST_IN"
            app:mask="@drawable/bottom_sheet_frame">
            <android.support.v7.widget.RecyclerView
                android:id="@+id/class_recycler"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/bottom_sheet_frame">
            </android.support.v7.widget.RecyclerView> 

</com.christophesmet.android.views.maskableframelayout.MaskableFrameLayout>

Here's the original recycler view without the maskable frame layout:

<android.support.v7.widget.RecyclerView
       android:id="@+id/class_recycler"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:background="@drawable/bottom_sheet_frame"> 
</android.support.v7.widget.RecyclerView>

From the layout code above, the original recycler view without the maskable layout allowed the elevation attribute for one of the items in the recycler view to render the drop shadow. However, when I enclosed it within the maskable layout, the shadows disappeared. Here's the view xml for the recycler view item:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@android:color/white">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="15dp"
        android:orientation="vertical"
        android:elevation="7dp"
        android:background="@drawable/button_active_bg">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dp"
            android:text="@string/level"
            android:gravity="center"
            android:textSize="12sp"
            android:layout_gravity="center"
            android:textColor="@android:color/black"/>
        <TextView
            android:id="@+id/column_floor_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingStart="45dp"
            android:paddingEnd="45dp"
            android:paddingBottom="10dp"
            android:text="G"
            android:textStyle="bold"
            android:gravity="center"
            android:textSize="24sp"
            android:layout_gravity="center"
            android:textColor="@android:color/black" />
    </LinearLayout>
    <TextView
        android:id="@+id/column_floor_cost"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="RM5.00/hr"
        android:textColor="@android:color/black"
        android:textSize="13sp"
        android:layout_gravity="center"
        android:gravity="center"
        android:paddingTop="8dp"
        android:paddingBottom="8dp"/>
</LinearLayout>

Note the linear layout contains elevation attribute set.

@NPatel1090
Copy link

I am still facing elevation issue. Can someone please help me solving this.

@christophesmet
Copy link
Owner

Hey all, sorry I seem to have not seen this at all.
Yes the mask layout will probably clip the shadows.
There is no automatic provide correct shadow masking from the mask provider.
However, this should fix it: https://developer.android.com/training/material/shadows-clipping
You can provide the shadow path with a ViewOutlineProvder as suggested on the documentation.
That should solve your problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants