florent37 / ShapeOfView

Give a custom shape to any android view, Material Design 2 ready
Apache License 2.0
3.12k stars 400 forks source link

Button elevation + animation elevation lost in DiagonalView #61

Open gm4s opened 5 years ago

gm4s commented 5 years ago

When I try to put a <Button> in the <DiagonalView> this one lost his elevation and on press elevation animation

<com.github.florent37.shapeofview.shapes.DiagonalView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:shape_diagonal_angle="10"
            app:shape_diagonal_position="bottom">

    <LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:background="@color/colorAccent"
                  android:orientation="vertical">

        <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/button_regular_height"
                android:layout_gravity="center"
                android:layout_marginStart="@dimen/button_regular_margin_start"
                android:layout_marginTop="@dimen/margin_regular_x2"
                android:layout_marginEnd="@dimen/button_regular_margin_end"
                android:layout_marginBottom="@dimen/margin_regular_x2"
                android:background="@drawable/button_white"
                android:ellipsize="end"
                android:enabled="false"
                android:maxLines="1"
                android:textAppearance="@style/DarwinBoldButton"
                android:textColor="@color/brightGray" />

    </LinearLayout>

</com.github.florent37.shapeofview.shapes.DiagonalView>

If I move the whole <LinearLayout><Button> out of <DiagonalView>, it's working correctly.

Any idea?

PS: Here is my custom button background

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:color="#33000000"
    tools:targetApi="lollipop">
    <item
        android:id="@android:id/mask"
        android:gravity="center">
        <shape>
            <solid android:color="@color/white" />
            <corners android:radius="@dimen/corner_radius_regular" />

        </shape>
    </item>
    <item android:id="@android:id/background">
        <shape>
            <solid android:color="@color/white" />
            <corners android:radius="@dimen/corner_radius_regular" />

        </shape>
    </item>
</ripple>