@Override public void hide() { CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) mAddToDoItemFAB.getLayoutParams(); int fabMargin = lp.bottomMargin; mAddToDoItemFAB.animate().translationY(mAddToDoItemFAB.getHeight() + fabMargin).setInterpolator(new AccelerateInterpolator(2.0f)).start(); } };
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); int fabBottomMargin = lp.bottomMargin; int distanceToScroll = child.getHeight() + fabBottomMargin;
int right = r.nextInt((screenWidth - Utils.dpToPx(16)) - 16) + 16; int bottom = r.nextInt((screenHeight - Utils.dpToPx(16)) - 16) + 16; CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); params.setMargins(Utils.dpToPx(16), Utils.dpToPx(16), right, bottom); fab.setLayoutParams(params);
@Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { if (floatingActionButton != null && floatingActionButton.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) floatingActionButton.getLayoutParams(); snackBarY = bottom - v.getY(); fabTargetOffset = fabDefaultBottomMargin - child.getTranslationY() + snackBarY; p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) fabTargetOffset); floatingActionButton.requestLayout(); } } });
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton fab, View dependency) { if (dependency instanceof AppBarLayout) { CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); int fabBottomMargin = lp.bottomMargin; int distanceToScroll = fab.getHeight() + fabBottomMargin; float ratio = dependency.getY() / toolbarHeight; fab.setTranslationY(distanceToScroll * ratio); } return true; } }
@Override public void hide() { CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams)mAddToDoItemFAB.getLayoutParams(); int fabMargin = lp.bottomMargin; mAddToDoItemFAB.animate().translationY(mAddToDoItemFAB.getHeight()+fabMargin).setInterpolator(new AccelerateInterpolator(2.0f)).start(); } };
@Override public void onCanSetLayoutParams() { // setMargins to fix floating action button's layout bug CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mFloatingActionButton .getLayoutParams(); params.setMargins(0, 0, 0, 0); mFloatingActionButton.setLayoutParams(params); } });
@Override public void onCanSetLayoutParams() { // setMargins to fix floating action button's layout bug CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) floatingActionButton .getLayoutParams(); params.setMargins(0, 0, 0, 0); floatingActionButton.setLayoutParams(params); } });
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton fab, View dependency) { boolean returnValue = super.onDependentViewChanged(parent, fab, dependency); if (dependency instanceof AppBarLayout) { CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); int fabBottomMargin = lp.bottomMargin; int distanceToScroll = fab.getHeight() + fabBottomMargin; float ratio = dependency.getY() / (float)toolbarHeight; fab.setTranslationY(-distanceToScroll * ratio); } return returnValue; }
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton fab, View dependency) { boolean returnValue = super.onDependentViewChanged(parent, fab, dependency); if (dependency instanceof AppBarLayout) { CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); int fabBottomMargin = lp.bottomMargin; int distanceToScroll = fab.getHeight() + fabBottomMargin; float ratio = dependency.getY()/(float)toolbarHeight; fab.setTranslationY(-distanceToScroll * ratio); } return returnValue; }
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton fab, View dependency) { boolean returnValue = super.onDependentViewChanged(parent, fab, dependency); if (dependency instanceof AppBarLayout) { CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); int fabBottomMargin = lp.bottomMargin; int distanceToScroll = fab.getHeight() + fabBottomMargin; float ratio = (float)dependency.getY()/(float)toolbarHeight; fab.setTranslationY(-distanceToScroll * ratio); } return returnValue; } }
@Override public void onAnimationEnd(Animation animation) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) fab3.getLayoutParams(); params.setMargins(0, 0, RADIUS, 0); fab3.setLayoutParams(params); fab3.clearAnimation(); }
@Override public void onAnimationEnd(Animation animation) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) fab2.getLayoutParams(); params.setMargins(0, 0, RADII, RADII); fab2.setLayoutParams(params); fab2.clearAnimation(); }
@Override public void onAnimationEnd(Animation animation) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) fab1.getLayoutParams(); params.setMargins(0, 0, 0, RADIUS); fab1.setLayoutParams(params); fab1.clearAnimation(); }
public void hideFab() { fab.clearAnimation(); Animation animation = AnimationUtils.loadAnimation(this, R.anim.hide_fab); fab.startAnimation(animation); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); FloatingActionButton.Behavior behavior = (FloatingActionButton.Behavior) params.getBehavior(); if (behavior != null) { behavior.setAutoHideEnabled(false); } fab.hide(); }
public void swappingFabUp() { fab.clearAnimation(); Animation animation = AnimationUtils.loadAnimation(this, R.anim.pop_up); fab.startAnimation(animation); fab.show(); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); FloatingActionButton.Behavior behavior = (FloatingActionButton.Behavior) params.getBehavior(); if (behavior != null) { behavior.setAutoHideEnabled(true); } }
@Override public void onAnimationEnd(Animation animation) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) fabMic.getLayoutParams(); params.setMargins(0, 0, 0, BIG_RADIUS); fabMic.setLayoutParams(params); fabMic.clearAnimation(); //notify the onDragListener that the items are ready for action IdeaMenuItemDragListener.setReady(true); }
@Override public void removeChatBox(boolean animToRight) { if (!searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text).hasFocus()) { hideSoftKeyBoard(); } AnimationHelper.hideViewX(chatBox, animToRight); //show fab button CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); RemoveViewsOnScroll removeViewsOnScroll = (RemoveViewsOnScroll) layoutParams.getBehavior(); removeViewsOnScroll.showView(fab); }
/** * Set margins for mini fab's. */ private void setupMarginsForMiniFab(Context context, FabWithTitleView FabWithTitleView) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { MarginLayoutParams miniFabParams = (MarginLayoutParams) FabWithTitleView.getFab().getLayoutParams(); miniFabParams.setMargins(0, 0, pxToDp(context, 12), 0); if (Build.VERSION.SDK_INT >= 17) miniFabParams.setMarginEnd(pxToDp(context, 12)); FabWithTitleView.getFab().setLayoutParams(miniFabParams); } }
@Override public void setLayoutBehaviour(LinearLayoutManager linearLayoutManager, RecyclerMessageAdapter adapter) { CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams(); layoutParams.setBehavior(new RemoveViewsOnScroll(linearLayoutManager, adapter)); appBarLayout.requestLayout(); layoutParams = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); layoutParams.setBehavior(new RemoveViewsOnScroll(linearLayoutManager, adapter)); fab.setLayoutParams(layoutParams); topSnackBar.setMessagesLayoutManager(linearLayoutManager); topSnackBar.setMessagesAdapter(adapter); }