balysv / material-ripple

Android L Ripple effect wrapper for Views
Apache License 2.0
2.36k stars 478 forks source link

Consider padding drawing ripple effect #78

Open altairmizuchi opened 7 years ago

altairmizuchi commented 7 years ago

Hi!!! I have next problem. I want to have ripple effect for button with custom shape. I wish I could use ripple xml but I need to support some older than 21 api devices. I also want my button to have height same to standard one. Because I use custom background I need to specify its size to 36dp manually. BUT... Google recommends to have 48 height touch zone for button with 36 dp.

If I do next

    <com.balysv.materialripple.MaterialRippleLayout
        app:mrl_rippleOverlay="true"
        android:id="@+id/btn_clear_all_btn"
        android:layout_width="wrap_content"
        android:layout_height="36dp"
        android:layout_alignTop="@id/fab_add_item"
        android:layout_centerHorizontal="true"
        app:mrl_rippleRoundedCorners="18dp">
        <TextView
            style="?attr/buttonStyle"
            android:background="@drawable/cashdup_button_black"
            android:text="@string/clear_all_weeks"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />
    </com.balysv.materialripple.MaterialRippleLayout>

I will have "incorrect" touch zone with 36 dp height. But if I do next

    <com.balysv.materialripple.MaterialRippleLayout
        app:mrl_rippleOverlay="true"
        android:id="@+id/btn_clear_all_btn"
        android:paddingBottom="6dp"
        android:paddingTop="6dp"
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:layout_alignTop="@id/fab_add_item"
        android:layout_centerHorizontal="true"
        app:mrl_rippleRoundedCorners="16dp">
        <TextView
            style="?attr/buttonStyle"
            android:background="@drawable/cashdup_button_black"
            android:text="@string/clear_all_weeks"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </com.balysv.materialripple.MaterialRippleLayout>

I will have incorrect ripple animation out of border. That's why it would be great if MaterialRippleLayout considers specified paddings for animation.

Thank you!

Splitters commented 6 years ago

I agree. That would make things easier.