Java Code Examples for com.google.android.material.floatingactionbutton.FloatingActionButton#show()
The following examples show how to use
com.google.android.material.floatingactionbutton.FloatingActionButton#show() .
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: FloatingActionButtonActions.java From material-components-android with Apache License 2.0 | 6 votes |
public static ViewAction hideThenShow() { return new ViewAction() { @Override public Matcher<View> getConstraints() { return isAssignableFrom(FloatingActionButton.class); } @Override public String getDescription() { return "Calls hide() then show()"; } @Override public void perform(UiController uiController, View view) { FloatingActionButton fab = (FloatingActionButton) view; fab.hide(); fab.show(); long duration = fab.getShowMotionSpec().getTotalDuration(); uiController.loopMainThreadForAtLeast(duration + 50); } }; }
Example 4
Source File: FloatingActionButtonActions.java From material-components-android with Apache License 2.0 | 6 votes |
public static ViewAction showThenHide() { return new ViewAction() { @Override public Matcher<View> getConstraints() { return isAssignableFrom(FloatingActionButton.class); } @Override public String getDescription() { return "Calls show() then hide()"; } @Override public void perform(UiController uiController, View view) { FloatingActionButton fab = (FloatingActionButton) view; fab.show(); fab.hide(); long duration = fab.getHideMotionSpec().getTotalDuration(); uiController.loopMainThreadForAtLeast(duration + 50); } }; }
Example 5
Source File: ProfileListFragment.java From SecondScreen with Apache License 2.0 | 6 votes |
@Override public void onStart() { super.onStart(); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, filter); // Floating action button FloatingActionButton floatingActionButton = getActivity().findViewById(R.id.button_floating_action); floatingActionButton.setImageResource(R.drawable.ic_action_new); if(getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")) floatingActionButton.hide(); if(getId() == R.id.profileViewEdit) { floatingActionButton.show(); floatingActionButton.setOnClickListener(v -> { DialogFragment newProfileFragment = new NewProfileDialogFragment(); newProfileFragment.show(getFragmentManager(), "new"); }); } }
Example 6
Source File: ScrollAwareFABBehavior.java From CustomBottomSheetBehavior with Apache License 2.0 | 5 votes |
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) { /** * Because we are not moving it, we always return false in this method. */ if (offset == 0) setOffsetValue(parent); if (mBottomSheetBehaviorRef == null) getBottomSheetBehavior(parent); int DyFix = getDyBetweenChildAndDependency(child, dependency); if ((child.getY() + DyFix) < offset) child.hide(); else if ((child.getY() + DyFix) >= offset) { /** * We are calculating every time point in Y where BottomSheet get {@link BottomSheetBehaviorGoogleMapsLike#STATE_COLLAPSED}. * If PeekHeight change dynamically we can reflect the behavior asap. */ if (mBottomSheetBehaviorRef == null || mBottomSheetBehaviorRef.get() == null) getBottomSheetBehavior(parent); int collapsedY = dependency.getHeight() - mBottomSheetBehaviorRef.get().getPeekHeight(); if ((child.getY() + DyFix) > collapsedY) child.hide(); else child.show(); } return false; }
Example 7
Source File: OdysseyMainActivity.java From odyssey with GNU General Public License v3.0 | 5 votes |
@Override public void setupFAB(View.OnClickListener listener) { FloatingActionButton playButton = findViewById(R.id.odyssey_play_button); if (playButton != null) { if (listener == null) { playButton.hide(); } else { playButton.show(); } playButton.setOnClickListener(listener); } }
Example 8
Source File: AppUtils.java From materialistic with Apache License 2.0 | 5 votes |
public static void toggleFab(FloatingActionButton fab, boolean visible) { if (visible) { fab.setTag(null); fab.show(); } else { fab.setTag(FabAwareScrollBehavior.HIDDEN); fab.hide(); } }
Example 9
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 10
Source File: SearchableBaseNoteFragment.java From nextcloud-notes with GNU General Public License v3.0 | 5 votes |
private void showSearchFabs() { FloatingActionButton next = getSearchNextButton(); FloatingActionButton prev = getSearchPrevButton(); if (prev != null) { prev.show(); } if (next != null) { next.show(); } }
Example 11
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(); } } }
Example 12
Source File: NoteListFragment.java From Notepad with Apache License 2.0 | 5 votes |
@Override public void onStart() { super.onStart(); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, filter); // Floating action button FloatingActionButton floatingActionButton = getActivity().findViewById(R.id.button_floating_action); floatingActionButton.setImageResource(R.drawable.ic_action_new); if(getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")) floatingActionButton.hide(); SharedPreferences prefMain = getActivity().getPreferences(Context.MODE_PRIVATE); if(getId() == R.id.noteViewEdit && prefMain.getLong("draft-name", 0) == 0) { floatingActionButton.show(); floatingActionButton.setOnClickListener(v -> { ScrollPositions.getInstance().setPosition(listView.getFirstVisiblePosition()); listener.getCabArray().clear(); Bundle bundle = new Bundle(); bundle.putString("filename", "new"); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle); // Add NoteEditFragment getFragmentManager() .beginTransaction() .replace(R.id.noteViewEdit, fragment, "NoteEditFragment") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE) .commit(); }); } }
Example 13
Source File: NoteListFragment.java From Notepad with Apache License 2.0 | 4 votes |
public void showFab() { FloatingActionButton floatingActionButton = getActivity().findViewById(R.id.button_floating_action); floatingActionButton.show(); }
Example 14
Source File: WelcomeFragment.java From Notepad with Apache License 2.0 | 4 votes |
public void showFab() { FloatingActionButton floatingActionButton = getActivity().findViewById(R.id.button_floating_action_welcome); floatingActionButton.show(); }
Example 15
Source File: FloatingActionButtonBindingAdapter.java From deagle with Apache License 2.0 | 4 votes |
@BindingAdapter("visible") public static void setVisible(final FloatingActionButton fab, final boolean visible) { if (visible) fab.show(); else fab.hide(); }
Example 16
Source File: DynamicFABUtils.java From dynamic-support with Apache License 2.0 | 2 votes |
/** * Same animation that FloatingActionButton.Behavior uses to show the FAB when the * AppBarLayout enters. * * @param fab The FAB to set show animation. */ public static void show(@NonNull FloatingActionButton fab) { fab.show(); }