FABProgressCircle icon indicating copy to clipboard operation
FABProgressCircle copied to clipboard

FAB does not move up to make space for a snackbar

Open AlexLardschneider opened this issue 9 years ago • 3 comments

Hi, the fab does not move up in order to make space for a Snackbar, like intended by the CoordinatorLayout behaviour.

AlexLardschneider avatar Dec 27 '15 14:12 AlexLardschneider

@AlexLardschneider You can create your own behavior (check this link https://github.com/ggajews/coordinatorlayoutwithfabdemo) and than assign it to your FabProgressCircleView like this

app:layout_behavior="your_behavior_path.FloatingActionBarBehavior"

use

public class FloatingActionButtonBehavior extends CoordinatorLayout.Behavior<FABProgressCircle>

instead of

public class FloatingActionButtonBehavior extends CoordinatorLayout.Behavior<FloatingActionButton>

barisemreefe avatar Feb 03 '16 09:02 barisemreefe

import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar.SnackbarLayout;
import android.util.AttributeSet;
import android.view.View;

import com.github.jorgecastilloprz.FABProgressCircle;

public class FloatingActionButtonBehaviour extends CoordinatorLayout.Behavior<FABProgressCircle> {

    public FloatingActionButtonBehaviour(Context context, AttributeSet attrs) {
    }

    @Override
    public boolean onDependentViewChanged(CoordinatorLayout parent, FABProgressCircle child, View dependency) {
        float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
        child.setTranslationY(translationY);
        return true;
    }

    @Override
    public boolean layoutDependsOn(CoordinatorLayout parent, FABProgressCircle child, View dependency) {
        return dependency instanceof SnackbarLayout;
    }
}
´´´

ScottEAdams avatar Feb 04 '16 03:02 ScottEAdams

Thank you @barisemreefe and @7wonders. It works like a charm!

sebasira avatar Jul 01 '16 20:07 sebasira