Java Code Examples for com.google.android.material.floatingactionbutton.FloatingActionButton#setBackgroundTintList()
The following examples show how to use
com.google.android.material.floatingactionbutton.FloatingActionButton#setBackgroundTintList() .
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: SatelliteMenuView.java From CrazyDaily with Apache License 2.0 | 6 votes |
public void setImgRes(ImgResEntity entity) { final Context context = getContext(); final int dp_6 = dp2px(context, 6); final int dp_3 = dp2px(context, 3); FloatingActionButton fab = new FloatingActionButton(context); fab.setPadding(dp_6, dp_6, dp_6, dp_6); fab.setElevation(dp_3); fab.setScaleType(ImageView.ScaleType.CENTER_INSIDE); fab.setSize(FloatingActionButton.SIZE_MINI); fab.setBackgroundTintList(ColorStateList.valueOf(entity.color)); fab.setImageResource(entity.res); fab.setUseCompatPadding(true); final int size = (int) (SIZE * BUTTON_RATIO); LayoutParams params = new LayoutParams(size, size); params.gravity = Gravity.END | Gravity.BOTTOM; addView(fab, params); mButtonView = fab; mButtonView.setOnClickListener(v -> { if (isOpen) { close(); } else { show(); } }); }
Example 2
Source File: CircleMenuView.java From circle-menu-android with MIT License | 6 votes |
private void initButtons(@NonNull Context context, @NonNull List<Integer> icons, @NonNull List<Integer> colors) { final int buttonsCount = Math.min(icons.size(), colors.size()); for (int i = 0; i < buttonsCount; i++) { final FloatingActionButton button = new FloatingActionButton(context); button.setImageResource(icons.get(i)); button.setBackgroundTintList(ColorStateList.valueOf(colors.get(i))); button.setClickable(true); button.setOnClickListener(new OnButtonClickListener()); button.setOnLongClickListener(new OnButtonLongClickListener()); button.setScaleX(0); button.setScaleY(0); button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); addView(button); mButtons.add(button); } }
Example 3
Source File: FloatingActionButtonActions.java From material-components-android with Apache License 2.0 | 6 votes |
public static ViewAction setBackgroundTintList(@ColorInt final ColorStateList tint) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return isAssignableFrom(FloatingActionButton.class); } @Override public String getDescription() { return "Sets FloatingActionButton background tint"; } @Override public void perform(UiController uiController, View view) { final FloatingActionButton fab = (FloatingActionButton) view; fab.setBackgroundTintList(tint); } }; }
Example 4
Source File: CustomDeviceActivity.java From voice-quickstart-android with MIT License | 5 votes |
private void applyFabState(FloatingActionButton button, boolean enabled) { // Set fab as pressed when call is on hold ColorStateList colorStateList = enabled ? ColorStateList.valueOf(ContextCompat.getColor(this, R.color.colorPrimaryDark)) : ColorStateList.valueOf(ContextCompat.getColor(this, R.color.colorAccent)); button.setBackgroundTintList(colorStateList); }
Example 5
Source File: VoiceActivity.java From voice-quickstart-android with MIT License | 5 votes |
private void applyFabState(FloatingActionButton button, boolean enabled) { // Set fab as pressed when call is on hold ColorStateList colorStateList = enabled ? ColorStateList.valueOf(ContextCompat.getColor(this, R.color.colorPrimaryDark)) : ColorStateList.valueOf(ContextCompat.getColor(this, R.color.colorAccent)); button.setBackgroundTintList(colorStateList); }
Example 6
Source File: CommonUtils.java From CommonUtils with Apache License 2.0 | 4 votes |
public static void setBackgroundColor(@NonNull FloatingActionButton fab, @ColorRes int color) { fab.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(fab.getContext(), color))); }
Example 7
Source File: BaseActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 4 votes |
protected void applyFABTheme(FloatingActionButton fab) { fab.setBackgroundTintList(ColorStateList.valueOf(customThemeWrapper.getColorPrimaryLightTheme())); fab.setImageTintList(ColorStateList.valueOf(customThemeWrapper.getFABIconColor())); }
Example 8
Source File: ThemePreviewActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 4 votes |
protected void applyFABTheme(FloatingActionButton fab) { fab.setBackgroundTintList(ColorStateList.valueOf(customTheme.colorPrimaryLightTheme)); fab.setImageTintList(ColorStateList.valueOf(customTheme.fabIconColor)); }
Example 9
Source File: FloatingActionButtonBindingAdapter.java From deagle with Apache License 2.0 | 4 votes |
@BindingAdapter("backgroundTint") public static void setBackgroundTint(final FloatingActionButton fab, final @ColorRes int bg_color_res) { fab.setBackgroundTintList(bg_color_res != 0 ? ColorStateList.valueOf(ContextCompat.getColor(fab.getContext(), bg_color_res)) : null); }
Example 10
Source File: FloatingActionButtonBindingAdapter.java From deagle with Apache License 2.0 | 4 votes |
@BindingAdapter("backgroundColor") public static void setBackgroundColor(final FloatingActionButton fab, final @ColorInt int bg_color) { fab.setBackgroundTintList(bg_color != 0 ? ColorStateList.valueOf(bg_color) : null); }