Java Code Examples for com.google.android.material.floatingactionbutton.FloatingActionButton#getVisibility()
The following examples show how to use
com.google.android.material.floatingactionbutton.FloatingActionButton#getVisibility() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FloatingActionButtonAnimBehavior.java From MultiTypeRecyclerViewAdapter with Apache License 2.0 | 6 votes |
@Override public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton 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) { // User scrolled down and the FAB is currently visible -> hide the FAB // animateOut(child); child.hide(new FloatingActionButton.OnVisibilityChangedListener() { @SuppressLint("RestrictedApi") @Override public void onHidden(FloatingActionButton fab) { fab.setVisibility(View.INVISIBLE); } }); } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) { // User scrolled up and the FAB is currently not visible -> show the FAB // animateIn(child); child.show(); } }
Example 2
Source File: ScrollAwareFabBehavior.java From UpdogFarmer with GNU General Public License v3.0 | 6 votes |
@Override public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull FloatingActionButton child, @NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) { super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type); if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) { child.hide(new FloatingActionButton.OnVisibilityChangedListener() { @Override public void onHidden(FloatingActionButton fab) { // GONE causes it to stop dispatching events... fab.setVisibility(View.INVISIBLE); } }); } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) { child.show(); } }
Example 3
Source File: ScrollAwareFABBehavior.java From FlexibleAdapter with Apache License 2.0 | 6 votes |
@Override public void onNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout, @NonNull final FloatingActionButton fab, @NonNull final View target, final int dxConsumed, final int dyConsumed, final int dxUnconsumed, final int dyUnconsumed, final int type) { super.onNestedScroll(coordinatorLayout, fab, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type); if (!enabled) return; if (dyConsumed > 0 && fab.getVisibility() == View.VISIBLE) { // User scrolled down and the FAB is currently visible -> hide the FAB fab.hide(); } else if (dyConsumed < 0 && fab.getVisibility() != View.VISIBLE) { // User scrolled up and the FAB is currently not visible -> show the FAB fab.postDelayed(new Runnable() { @Override public void run() { fab.show(); } }, 200L); } }
Example 4
Source File: FabScaleBehavior.java From NewFastFrame with Apache License 2.0 | 5 votes |
@Override public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull FloatingActionButton child, @NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) { if ((dyConsumed > 0 || dyUnconsumed > 0) && !isAnimatingOut && child.getVisibility() == View.VISIBLE) {//往下滑 child.setVisibility(View.INVISIBLE); AnimatorUtil.scaleHide(child, viewPropertyAnimatorListener); if (mOnStateChangedListener != null) { mOnStateChangedListener.onChanged(false); } } else if ((dyConsumed < 0 || dyUnconsumed < 0) && child.getVisibility() != View.VISIBLE) { AnimatorUtil.scaleShow(child, null); if (mOnStateChangedListener != null) { mOnStateChangedListener.onChanged(true); } } }
Example 5
Source File: ScrollAwareFABBehavior.java From Easy_xkcd with Apache License 2.0 | 5 votes |
@Override public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) { child.hide(); } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) { child.show(); child.setVisibility(View.VISIBLE); } }
Example 6
Source File: FABHideOnScrollBehavior.java From hipda with GNU General Public License v2.0 | 5 votes |
@Override public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); boolean isNearBottom = target instanceof XRecyclerView && ((XRecyclerView) target).isNearBottom(); if (isNearBottom && child.getVisibility() == View.INVISIBLE) { child.show(); } else { if (!isNearBottom && dyConsumed > 0 && child.getVisibility() == View.VISIBLE) { hideFab(child); } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) { child.show(); } } }