ebanx / swipe-button

A button that activates by swipe instead of touch
487 stars 101 forks source link

How to alter the button as the below image #13

Open nidhinprathap opened 7 years ago

nidhinprathap commented 7 years ago

this. Plus on slide the slided areas color should change to the buttons color.

Can u guide me in this

leandroBorgesFerreira commented 7 years ago

I believe you should use a custom shape for the moving part of the button. Did you try to do that?

nidhinprathap commented 7 years ago

i added it as an image.. my issue is how to color the background of the swiped area while swipping

leandroBorgesFerreira commented 7 years ago

I see. This library doesn't support this behavior right now. You can add this functionality in a pull request, if you have time. If think it is a really nice behavior, I will add this in the future.

leandroBorgesFerreira commented 7 years ago

Hello @nidhinprathap. A trailing effect was added by @rahulk11 in the version 0.8.0. You can use this version to achieve the behavior that you need. But there's still a problem with the corners of the button during the slide, so I won't close this issue.

leandroBorgesFerreira commented 7 years ago

The problem was solved in the version 0.8.1

leandroBorgesFerreira commented 7 years ago

I reopened this issue as this is not only a feature request...

@nidhinprathap Try to use the new functionalities of the button to achieve the behavior that you need. Please let me know if the trailing effect solves your problem.

nidhinprathap commented 7 years ago

Somewhat does the part. Here is a bug fix :

SwipeButton.java

function setTrailingEffect

its crashing if no trailingDrawable has been assigned.

Just add this and declare trailingDrawable class level;

private void setTrailingEffect() {
        if (trailEnabled && trailingDrawable != null && layer != null) {
            layer.setVisibility(View.VISIBLE);
            layer.setLayoutParams(new RelativeLayout.LayoutParams(
                    (int) (swipeButtonInner.getX() + swipeButtonInner.getWidth()),
                    swipeButtonInner.getHeight()));
        }
    }
leandroBorgesFerreira commented 7 years ago

@nidhinprathap I believe that the developers would be confused when they set the trail effect to true and nothing happens. Instead of checking for null only in the execution of the animation, I am now throwing an exception in the creation of the button with an easy to understand message asking for the drawable. This is available in the 0.8.2 version.

nidhinprathap commented 7 years ago

Ok great.

nidhinprathap commented 7 years ago

Or u can just used button_background , if button_trail_drawable

is not specified and if button_trail_enabled is enabled

leandroBorgesFerreira commented 7 years ago

This seams good. I will take look at this later.

leandroBorgesFerreira commented 7 years ago

Now it doesn't throw the error anymore. It uses the background from the button if the trailing background is not set.