Comments (4)
This is not really an issue. CoordinatorLayout
uses Behavior
s to collapse or move anything in it. Any View
can have its own Behavior
. FloatingActionButton
has its Behavior
set to collapse.
You should be able to fix this by setting your own custom Behavior
manually.
For more information read the documentation: https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.html
from fabprogresscircle.
Behaviors
import android.content.Context;
import android.os.Build;
import android.support.design.widget.CoordinatorLayout;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorListener;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
import tatbigy.ultrahd.R;
public class FABProgressCircleBehavior extends CoordinatorLayout.Behavior {
private static final Interpolator INTERPOLATOR = new FastOutSlowInInterpolator();
private boolean mIsAnimatingOut = false;
public FABProgressCircleBehavior(Context context, AttributeSet attrs) {
super();
}
@Override
public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FrameLayout child,
final View directTargetChild, final View target, final int nestedScrollAxes) {
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL
|| super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
}
@Override
public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final FrameLayout child,
final View target, final int dxConsumed, final int dyConsumed,
final int dxUnconsumed, final int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
if (dyConsumed > 0 && !this.mIsAnimatingOut && child.getVisibility() == View.VISIBLE) {
animateOut(child);
} else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
animateIn(child);
}
}
// Same animation that FloatingActionButton.Behavior uses to hide the FAB when the AppBarLayout exits
private void animateOut(final FrameLayout button) {
if (Build.VERSION.SDK_INT >= 14) {
ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR).withLayer()
.setListener(new ViewPropertyAnimatorListener() {
public void onAnimationStart(View view) {
FABProgressCircleBehavior.this.mIsAnimatingOut = true;
}
public void onAnimationCancel(View view) {
FABProgressCircleBehavior.this.mIsAnimatingOut = false;
}
public void onAnimationEnd(View view) {
FABProgressCircleBehavior.this.mIsAnimatingOut = false;
view.setVisibility(View.GONE);
}
}).start();
} else {
Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_out);
anim.setInterpolator(INTERPOLATOR);
anim.setDuration(200L);
anim.setAnimationListener(new Animation.AnimationListener() {
public void onAnimationStart(Animation animation) {
FABProgressCircleBehavior.this.mIsAnimatingOut = true;
}
public void onAnimationEnd(Animation animation) {
FABProgressCircleBehavior.this.mIsAnimatingOut = false;
button.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(final Animation animation) {
}
});
button.startAnimation(anim);
}
}
// Same animation that FloatingActionButton.Behavior uses to show the FAB when the AppBarLayout enters
private void animateIn(FrameLayout button) {
button.setVisibility(View.VISIBLE);
if (Build.VERSION.SDK_INT >= 14) {
ViewCompat.animate(button).scaleX(1.0F).scaleY(1.0F).alpha(1.0F)
.setInterpolator(INTERPOLATOR).withLayer().setListener(null)
.start();
} else {
Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_in);
anim.setDuration(200L);
anim.setInterpolator(INTERPOLATOR);
button.startAnimation(anim);
}
}
}
from fabprogresscircle.
Can you please post a full sample code of your suggestion? Unfortunately I cannot get it working with the code that is given
from fabprogresscircle.
I have tried to backport @CoordinatorLayout.DefaultBehavior(FloatingActionButton.Behavior.class), but unsuccessfully. Does anyone succeeded on creating a custom behavior for the FabProgressCircle ?
from fabprogresscircle.
Related Issues (20)
- Different arcColor for the final aspect
- finish animation relative to Volley call
- Strange error trying to cast FABProgessCircle as FloatingActionButton HOT 3
- FABPC + CoordinatorLayout in Fragment + TabLayout = Wrong Placement HOT 2
- Finish animation speed
- beginFinalAnimation() NullPointerException
- Animation is very fast
- Elevation attribute not working
- Customizable Animation Times
- The progress circle is getting cut-off/clipped. It's never a smooth circle for me. HOT 4
- Can't increase size of progress circle
- Not show animation in ConstraintLayout
- Without click, crash and shows null pointer exception
- Can not beginFinalAnimation in recyclerView
- How change image resource back to previous? HOT 1
- Final image not showing HOT 1
- Progress circle set reusable from code
- unable to change finalIcon programatically and fab background color
- Module realized via code
- call show and hide in row HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fabprogresscircle.