Java Code Examples for com.google.android.material.floatingactionbutton.FloatingActionButton#setTag()
The following examples show how to use
com.google.android.material.floatingactionbutton.FloatingActionButton#setTag() .
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: BookFloatingActionMenu.java From HaoReader with GNU General Public License v3.0 | 6 votes |
@SuppressLint("ClickableViewAccessibility") private void initFloatingActionMenu() { for (int i = 0; i <= getChildCount() - 2; i++) { ViewGroup childGroup = (ViewGroup) getChildAt(i); final int index = Integer.parseInt(String.valueOf(childGroup.getTag())); childGroup.setVisibility(INVISIBLE); View labelView = childGroup.getChildAt(0); labelView.setVisibility(INVISIBLE); FloatingActionButton btnView = (FloatingActionButton) childGroup.getChildAt(1); btnView.setTag(btnView.getDrawable()); if (mLastIndex == index) { btnView.setImageResource(R.drawable.ic_check_black_24dp); } labelView.setOnClickListener(v -> btnView.callOnClick()); btnView.setOnClickListener(v -> { setSelection(index); collapse(); if (mMenuClickListener != null) { mMenuClickListener.onMenuClick(index, v); } }); btnView.post(btnView::hide); } }
Example 2
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 3
Source File: FloatingActionButtonBehavior.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 4 votes |
private static void hide(FloatingActionButton fab) { fab.setTag(false); fab.animate().scaleX(0).scaleY(0).setDuration(DURATION).start(); fab.setClickable(false); }
Example 4
Source File: FloatingActionButtonBehavior.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 4 votes |
private static void show(FloatingActionButton fab) { fab.setTag(true); fab.animate().scaleX(1).scaleY(1).setDuration(DURATION).start(); fab.setClickable(true); }
Example 5
Source File: FloatingActionButtonBehavior.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 4 votes |
@Override public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull FloatingActionButton child, @NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, @NonNull int[] consumed) { if (child.getTag() == null) child.setTag(true); if (dyConsumed > 0 && ((boolean) child.getTag())) hide(child); else if (dyConsumed < 0 && (!(boolean) child.getTag())) show(child); }
Example 6
Source File: FABMenu.java From Jockey with Apache License 2.0 | 4 votes |
private FloatingActionButton buildChild(@DrawableRes int icon, final OnClickListener onClickListener, String label) { FloatingActionButton button = LayoutInflater.from(getContext()) .inflate(R.layout.mini_fab, (ViewGroup) getParent(), true) .findViewWithTag("fab-null"); button.setTag("fab-" + label); button.setImageResource(icon); button.setVisibility(GONE); button.setOnClickListener(v -> { onClickListener.onClick(v); hideChildren(); }); if (getParent() instanceof CoordinatorLayout) { final float padding = getResources().getDimension(R.dimen.fab_margin); final float dpScale = getResources().getDisplayMetrics().density; CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) button.getLayoutParams(); if (ViewUtils.isRtl(getContext())) { params.leftMargin += padding; } else { params.rightMargin += padding; } params.bottomMargin = (int) (SIZE_L_DP * dpScale + padding * (2 + children.size()) + SIZE_S_DP * dpScale * children.size()); // For some reason, the children are 12dp higher and 18dp further to the left on pre-L // devices than on L+ devices. I don't know for sure what causes this (I suspect it's // the drop shadow or elevation compatibility code), but this takes care of it. // // There's probably a better way to fix this, but this was the easiest. If for some // reason this changes in an update to one of the support libraries, just remeasure // these offsets and update them here. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { if (ViewUtils.isRtl(getContext())) { params.leftMargin -= 12 * dpScale; } else { params.rightMargin -= 12 * dpScale; } params.bottomMargin -= 18 * dpScale; } button.setLayoutParams(params); } else { Timber.e("Parent must be a CoordinatorLayout to properly set margin"); } // When children aren't visible on screen, remove them from the view hierarchy completely // If we don't do this, then the FloatingActionButton Behaviors conflict for some reason // and Snackbars won't slide the FAB up which is kind of an important detail. // // FABMenu.Behavior takes care of some of the left over discrepancies like overlapping FAB's // // Additionally, the screen is functionally important because it prevents the user // from doing something that could generate a Snackbar when the FAB's are visible // which can cause the main FAB to be overlapped. ((ViewGroup) button.getParent()).removeView(button); return button; }