Java Code Examples for android.support.design.widget.FloatingActionButton#setImageTintList()
The following examples show how to use
android.support.design.widget.FloatingActionButton#setImageTintList() .
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: FabSpeedDial.java From FireFiles with Apache License 2.0 | 6 votes |
private void setupFab() { // Set up the client's FAB fab = (FloatingActionButton) findViewById(R.id.fab); fab.setImageDrawable(fabDrawable); if (Utils.hasLollipop()) { fab.setImageTintList(fabDrawableTint); } if (fabBackgroundTint != null) { fab.setBackgroundTintList(fabBackgroundTint); } fab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (isAnimating) return; if (isMenuOpen()) { closeMenu(); } else { openMenu(); } } }); }
Example 2
Source File: FabSpeedDial.java From FireFiles with Apache License 2.0 | 6 votes |
private void setupFab() { // Set up the client's FAB fab = (FloatingActionButton) findViewById(R.id.fab); fab.setImageDrawable(fabDrawable); if (Utils.hasLollipop()) { fab.setImageTintList(fabDrawableTint); } if (fabBackgroundTint != null) { fab.setBackgroundTintList(fabBackgroundTint); } fab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (isAnimating) return; if (isMenuOpen()) { closeMenu(); } else { openMenu(); } } }); }
Example 3
Source File: FabSpeedDial.java From FireFiles with Apache License 2.0 | 6 votes |
private void setupFab() { // Set up the client's FAB fab = (FloatingActionButton) findViewById(R.id.fab); fab.setImageDrawable(fabDrawable); if (Utils.hasLollipop()) { fab.setImageTintList(fabDrawableTint); } if (fabBackgroundTint != null) { fab.setBackgroundTintList(fabBackgroundTint); } fab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (isAnimating) return; if (isMenuOpen()) { closeMenu(); } else { openMenu(); } } }); }
Example 4
Source File: FabSpeedDial.java From FireFiles with Apache License 2.0 | 5 votes |
private View createFabMenuItem(MenuItem menuItem) { ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext()) .inflate(getMenuItemLayoutId(), this, false); FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab); FrameLayout cardView = (FrameLayout) fabMenuItem.findViewById(R.id.card_view); TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view); fabMenuItemMap.put(miniFab, menuItem); cardViewMenuItemMap.put(cardView, menuItem); miniFab.setImageDrawable(menuItem.getIcon()); miniFab.setOnClickListener(this); cardView.setOnClickListener(this); ViewCompat.setAlpha(miniFab, 0f); ViewCompat.setAlpha(cardView, 0f); final CharSequence title = menuItem.getTitle(); if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) { //cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor()); titleView.setText(title); titleView.setTypeface(null, Typeface.BOLD); titleView.setTextColor(miniFabTitleTextColor); } else { fabMenuItem.removeView(cardView); } miniFab.setBackgroundTintList(miniFabBackgroundTint); if (Utils.hasLollipop()) { miniFab.setImageTintList(miniFabDrawableTint); } return fabMenuItem; }
Example 5
Source File: FabSpeedDial.java From FireFiles with Apache License 2.0 | 5 votes |
private View createFabMenuItem(MenuItem menuItem) { ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext()) .inflate(getMenuItemLayoutId(), this, false); FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab); FrameLayout cardView = (FrameLayout) fabMenuItem.findViewById(R.id.card_view); TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view); fabMenuItemMap.put(miniFab, menuItem); cardViewMenuItemMap.put(cardView, menuItem); miniFab.setImageDrawable(menuItem.getIcon()); miniFab.setOnClickListener(this); cardView.setOnClickListener(this); ViewCompat.setAlpha(miniFab, 0f); ViewCompat.setAlpha(cardView, 0f); final CharSequence title = menuItem.getTitle(); if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) { //cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor()); titleView.setText(title); titleView.setTypeface(null, Typeface.BOLD); titleView.setTextColor(miniFabTitleTextColor); } else { fabMenuItem.removeView(cardView); } miniFab.setBackgroundTintList(miniFabBackgroundTint); if (Utils.hasLollipop()) { miniFab.setImageTintList(miniFabDrawableTint); } return fabMenuItem; }
Example 6
Source File: FabSpeedDial.java From FireFiles with Apache License 2.0 | 5 votes |
private View createFabMenuItem(MenuItem menuItem) { ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext()) .inflate(getMenuItemLayoutId(), this, false); FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab); FrameLayout cardView = (FrameLayout) fabMenuItem.findViewById(R.id.card_view); TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view); fabMenuItemMap.put(miniFab, menuItem); cardViewMenuItemMap.put(cardView, menuItem); miniFab.setImageDrawable(menuItem.getIcon()); miniFab.setOnClickListener(this); cardView.setOnClickListener(this); ViewCompat.setAlpha(miniFab, 0f); ViewCompat.setAlpha(cardView, 0f); final CharSequence title = menuItem.getTitle(); if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) { //cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor()); titleView.setText(title); titleView.setTypeface(null, Typeface.BOLD); titleView.setTextColor(miniFabTitleTextColor); } else { fabMenuItem.removeView(cardView); } miniFab.setBackgroundTintList(miniFabBackgroundTint); if (Utils.hasLollipop()) { miniFab.setImageTintList(miniFabDrawableTint); } return fabMenuItem; }
Example 7
Source File: FabSpeedDial.java From fab-speed-dial with Apache License 2.0 | 4 votes |
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); int coordinatorLayoutOffset = getResources().getDimensionPixelSize(R.dimen.coordinator_layout_offset); if (fabGravity == BOTTOM_END || fabGravity == TOP_END) { layoutParams.setMargins(0, 0, coordinatorLayoutOffset, 0); } else { layoutParams.setMargins(coordinatorLayoutOffset, 0, 0, 0); } menuItemsLayout.setLayoutParams(layoutParams); // Set up the client's FAB fab = (FloatingActionButton) findViewById(R.id.fab); fab.setImageDrawable(fabDrawable); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { fab.setImageTintList(fabDrawableTint); } if (fabBackgroundTint != null) { fab.setBackgroundTintList(fabBackgroundTint); } fab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (isAnimating) return; if (isMenuOpen()) { closeMenu(); } else { openMenu(); } } }); // Needed in order to intercept key events setFocusableInTouchMode(true); if (useTouchGuard) { ViewParent parent = getParent(); touchGuard = new View(getContext()); touchGuard.setOnClickListener(this); touchGuard.setWillNotDraw(true); touchGuard.setVisibility(GONE); if (touchGuardDrawable != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { touchGuard.setBackground(touchGuardDrawable); } else { touchGuard.setBackgroundDrawable(touchGuardDrawable); } } if (parent instanceof FrameLayout) { FrameLayout frameLayout = (FrameLayout) parent; frameLayout.addView(touchGuard); bringToFront(); } else if (parent instanceof CoordinatorLayout) { CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent; coordinatorLayout.addView(touchGuard); bringToFront(); } else if (parent instanceof RelativeLayout) { RelativeLayout relativeLayout = (RelativeLayout) parent; relativeLayout.addView(touchGuard, new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); bringToFront(); } else { Log.d(TAG, "touchGuard requires that the parent of this FabSpeedDialer be a FrameLayout or RelativeLayout"); } } setOnClickListener(this); if (shouldOpenMenu) openMenu(); }
Example 8
Source File: FabSpeedDial.java From fab-speed-dial with Apache License 2.0 | 4 votes |
private View createFabMenuItem(MenuItem menuItem) { ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext()) .inflate(getMenuItemLayoutId(), this, false); FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab); CardView cardView = (CardView) fabMenuItem.findViewById(R.id.card_view); TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view); fabMenuItemMap.put(miniFab, menuItem); cardViewMenuItemMap.put(cardView, menuItem); miniFab.setImageDrawable(menuItem.getIcon()); miniFab.setOnClickListener(this); cardView.setOnClickListener(this); ViewCompat.setAlpha(miniFab, 0f); ViewCompat.setAlpha(cardView, 0f); final CharSequence title = menuItem.getTitle(); if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) { cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor()); titleView.setText(title); titleView.setTypeface(null, Typeface.BOLD); titleView.setTextColor(miniFabTitleTextColor); if (miniFabTitleTextColorArray != null) { titleView.setTextColor(ContextCompat.getColorStateList(getContext(), miniFabTitleTextColorArray[menuItem.getOrder()])); } } else { fabMenuItem.removeView(cardView); } miniFab.setBackgroundTintList(miniFabBackgroundTint); if (miniFabBackgroundTintArray != null) { miniFab.setBackgroundTintList(ContextCompat.getColorStateList(getContext(), miniFabBackgroundTintArray[menuItem.getOrder()])); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { miniFab.setImageTintList(miniFabDrawableTint); } return fabMenuItem; }
Example 9
Source File: FabSpeedDial.java From fab-speed-dial with Apache License 2.0 | 4 votes |
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); int coordinatorLayoutOffset = getResources().getDimensionPixelSize(R.dimen.coordinator_layout_offset); if (fabGravity == BOTTOM_END || fabGravity == TOP_END) { layoutParams.setMargins(0, 0, coordinatorLayoutOffset, 0); } else { layoutParams.setMargins(coordinatorLayoutOffset, 0, 0, 0); } menuItemsLayout.setLayoutParams(layoutParams); // Set up the client's FAB fab = (FloatingActionButton) findViewById(R.id.fab); fab.setImageDrawable(fabDrawable); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { fab.setImageTintList(fabDrawableTint); } if (fabBackgroundTint != null) { fab.setBackgroundTintList(fabBackgroundTint); } fab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (isAnimating) return; if (isMenuOpen()) { closeMenu(); } else { openMenu(); } } }); // Needed in order to intercept key events setFocusableInTouchMode(true); if (useTouchGuard) { ViewParent parent = getParent(); touchGuard = new View(getContext()); touchGuard.setOnClickListener(this); touchGuard.setWillNotDraw(true); touchGuard.setVisibility(GONE); if (touchGuardDrawable != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { touchGuard.setBackground(touchGuardDrawable); } else { touchGuard.setBackgroundDrawable(touchGuardDrawable); } } if (parent instanceof FrameLayout) { FrameLayout frameLayout = (FrameLayout) parent; frameLayout.addView(touchGuard); bringToFront(); } else if (parent instanceof CoordinatorLayout) { CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent; coordinatorLayout.addView(touchGuard); bringToFront(); } else if (parent instanceof RelativeLayout) { RelativeLayout relativeLayout = (RelativeLayout) parent; relativeLayout.addView(touchGuard, new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); bringToFront(); } else { Log.d(TAG, "touchGuard requires that the parent of this FabSpeedDialer be a FrameLayout or RelativeLayout"); } } setOnClickListener(this); if (shouldOpenMenu) openMenu(); }
Example 10
Source File: FabSpeedDial.java From fab-speed-dial with Apache License 2.0 | 4 votes |
private View createFabMenuItem(MenuItem menuItem) { ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext()) .inflate(getMenuItemLayoutId(), this, false); FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab); CardView cardView = (CardView) fabMenuItem.findViewById(R.id.card_view); TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view); fabMenuItemMap.put(miniFab, menuItem); cardViewMenuItemMap.put(cardView, menuItem); miniFab.setImageDrawable(menuItem.getIcon()); miniFab.setOnClickListener(this); cardView.setOnClickListener(this); ViewCompat.setAlpha(miniFab, 0f); ViewCompat.setAlpha(cardView, 0f); final CharSequence title = menuItem.getTitle(); if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) { cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor()); titleView.setText(title); titleView.setTypeface(null, Typeface.BOLD); titleView.setTextColor(miniFabTitleTextColor); if (miniFabTitleTextColorArray != null) { titleView.setTextColor(ContextCompat.getColorStateList(getContext(), miniFabTitleTextColorArray[menuItem.getOrder()])); } } else { fabMenuItem.removeView(cardView); } miniFab.setBackgroundTintList(miniFabBackgroundTint); if (miniFabBackgroundTintArray != null) { miniFab.setBackgroundTintList(ContextCompat.getColorStateList(getContext(), miniFabBackgroundTintArray[menuItem.getOrder()])); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { miniFab.setImageTintList(miniFabDrawableTint); } return fabMenuItem; }