当前位置: 首页>>代码示例>>Java>>正文


Java FloatingActionButton.setBackgroundTintList方法代码示例

本文整理汇总了Java中android.support.design.widget.FloatingActionButton.setBackgroundTintList方法的典型用法代码示例。如果您正苦于以下问题:Java FloatingActionButton.setBackgroundTintList方法的具体用法?Java FloatingActionButton.setBackgroundTintList怎么用?Java FloatingActionButton.setBackgroundTintList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.design.widget.FloatingActionButton的用法示例。


在下文中一共展示了FloatingActionButton.setBackgroundTintList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupFab

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
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();
            }
        }
    });
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:25,代码来源:FabSpeedDial.java

示例2: initButtons

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:Ramotion,项目名称:circle-menu-android,代码行数:18,代码来源:CircleMenuView.java

示例3: onThemeApplied

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
public void onThemeApplied(Theme theme) {
    if (pick_photos) {
        return;
    }

    final Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setBackgroundColor(toolbarColor);
    toolbar.setTitleTextColor(textColorPrimary);

    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setBackgroundTintList(ColorStateList.valueOf(accentColor));

    if (theme.darkStatusBarIcons()) {
        Util.setDarkStatusBarIcons(findViewById(R.id.root_view));
    } else {
        Util.setLightStatusBarIcons(findViewById(R.id.root_view));
    }

    if (theme.statusBarOverlay()) {
        addStatusBarOverlay(toolbar);
    }
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:24,代码来源:AlbumActivity.java

示例4: setFAB

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private void setFAB() {
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    if(fabColor != null)
        fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor(fabColor)));
    if(fabDrawable != null){
        Bitmap customFabIcon = PickerUtils.extractDrawable(fabDrawable);
        if(customFabIcon != null)
            fab.setImageBitmap(customFabIcon);
    }

    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TreeSet<SimpleContact> selected = mFragment.getSelected();
            Intent result = new Intent();
            result.putExtra(CP_SELECTED_CONTACTS, selected);
            setResult(RESULT_OK,result);
            finish();
        }
    });
}
 
开发者ID:quiin,项目名称:UnifiedContactPicker,代码行数:22,代码来源:ContactPickerActivity.java

示例5: addColorButton

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private void addColorButton(){
    for(int i=0;i<12;i++){
        FloatingActionButton floatingActionButton = new FloatingActionButton(CanvasActivity.this);
        floatingActionButton.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor(colorArr[i])));
        floatingActionButton.setCompatElevation(0);
        floatingActionButton.setTag("button");

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(108,108);
        params.setMargins(32,0,32,0);
        final RelativeLayout relativeLayout = new RelativeLayout(CanvasActivity.this);
        relativeLayout.addView(floatingActionButton, params);
        relativeLayout.setOnClickListener(this);
        if(i == 11){
            relativeLayout.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View view) {
                    setDialog((FloatingActionButton) view.findViewWithTag("button"));
                    relativeLayout.callOnClick();
                    return true;
                }
            });
        }

        if(i > 5){
            colorSelectLayout2.addView(relativeLayout, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT));
        }else{
            colorSelectLayout1.addView(relativeLayout, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT));
        }
    }
}
 
开发者ID:DSM-GRAM,项目名称:Artist,代码行数:31,代码来源:CanvasActivity.java

示例6: setSecondaryBackgroundTintList

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
/**
 * Applies a tint to the background drawable. Does not modify the current tint
 * mode, which is {@link PorterDuff.Mode#SRC_IN} by default.
 *
 * @param tint the tint to apply, may be {@code null} to clear tint
 */
public void setSecondaryBackgroundTintList(@Nullable ColorStateList tint) {
    if (miniFabBackgroundTint != tint) {
        miniFabBackgroundTint = tint;
        for(FloatingActionButton miniFab : fabMenuItemMap.keySet()) {
            miniFab.setBackgroundTintList(tint);
        }
    }
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:15,代码来源:FabSpeedDial.java

示例7: setFabBackgroundTint

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
public static void setFabBackgroundTint(FloatingActionButton fab, int color) {
    ColorStateList fabColorStateList = new ColorStateList(
            new int[][]{
                    new int[]{}
            },
            new int[]{
                    color,
            }
    );
    fab.setBackgroundTintList(fabColorStateList);
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:12,代码来源:ATEUtils.java

示例8: createFabMenuItem

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
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;
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:36,代码来源:FabSpeedDial.java

示例9: initFab

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void initFab(FloatingActionButton fab) {
    fab.setVisibility(View.GONE);
    fab.setImageResource(R.drawable.ic_drawer);
    fab.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorPrimary)));
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:7,代码来源:ZhihuStoryDetailViewModel.java

示例10: initFab

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void initFab(FloatingActionButton fab) {
    fab.setSize(FloatingActionButton.SIZE_MINI);
    fab.setImageResource(R.drawable.ic_up);
    fab.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorPrimary)));
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:7,代码来源:DoubanMovieMoreReviewViewModel.java

示例11: initFab

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void initFab(FloatingActionButton fab) {
    fab.setVisibility(View.GONE);
    fab.setImageResource(R.drawable.ic_share);
    fab.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorPrimary)));
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:7,代码来源:DoubanMovieDetailViewModel.java

示例12: initFab

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void initFab(FloatingActionButton fab) {
    fab.setSize(FloatingActionButton.SIZE_MINI);
    fab.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorPrimary)));
    fab.setImageResource(R.drawable.ic_up);
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:7,代码来源:MainViewModel.java

示例13: updateFab

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
/**
 * Update FAB's look and action
 */
public static void updateFab(FragmentActivity activity, String fragmentTag, int selectionCount) {
    FloatingActionButton fab = (FloatingActionButton) activity.findViewById(R.id.fab);

    if (fab == null) {
        return;
    }

    Fragment fragment = activity.getSupportFragmentManager().findFragmentByTag(fragmentTag);

    if (fragment == null) {
        fab.hide();
        return;
    }

    /* Hide FAB if there are selected notes. */
    if (selectionCount > 0) {
        fab.hide();
        return;
    }


    if (fragment instanceof Fab) {
        final Runnable fabAction = ((Fab) fragment).getFabAction();
        ActivityUtils.FragmentResources resources = new ActivityUtils.FragmentResources(activity, fragmentTag);

        if (resources.fabDrawable != null && fabAction != null) {
            fab.show();

            fab.setBackgroundTintList(ColorStateList.valueOf(resources.actionColor));
            fab.setImageDrawable(resources.fabDrawable);

            fab.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    fabAction.run();
                }
            });

        } else {
            fab.hide();
        }
    } else {
        fab.hide();
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:49,代码来源:MainFab.java

示例14: NumberPadTimePickerBottomSheetComponent

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
NumberPadTimePickerBottomSheetComponent(final NumberPadTimePicker timePicker, Context context,
        AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(timePicker, context, attrs, defStyleAttr, defStyleRes);
    mOkButton = (FloatingActionButton) checkNotNull(super.mOkButton);
    
    final TypedArray timePickerAttrs = context.obtainStyledAttributes(attrs,
            R.styleable.NPTP_NumberPadTimePicker, defStyleAttr, defStyleRes);

    final ColorStateList fabBackgroundColor = retrieveFabBackgroundColor(
            timePickerAttrs, context);
    // If we could not create a default ColorStateList, then just leave the current
    // stateless color as is. If the color is stateless, we ignore the value for
    // animateFabBackgroundColor because there is nothing to animate.
    if (fabBackgroundColor != null) {
        final boolean animateFabBackgroundColor = timePickerAttrs.getBoolean(R.styleable.
                NPTP_NumberPadTimePicker_nptp_animateFabBackgroundColor, true);
        setAnimateFabBackgroundColor(animateFabBackgroundColor, fabBackgroundColor, context);
        mOkButton.setBackgroundTintList(fabBackgroundColor);
    }

    final int fabRippleColor = timePickerAttrs.getColor(R.styleable.
            NPTP_NumberPadTimePicker_nptp_fabRippleColor, 0);
    if (fabRippleColor != 0) {
        setFabRippleColor(fabRippleColor);
    }

    mAnimateFabIn = timePickerAttrs.getBoolean(R.styleable.
            NPTP_NumberPadTimePicker_nptp_animateFabIn, false);
    mShowFabPolicy = retrieveShowFab(timePickerAttrs);
    setInitialFabVisibility(mAnimateFabIn, mShowFabPolicy);

    mBackspaceLocation = retrieveBackspaceLocation(timePickerAttrs);
    applyBackspaceLocation();

    final ColorStateList fabIconTint = timePickerAttrs.getColorStateList(
            R.styleable.NPTP_NumberPadTimePicker_nptp_fabIconTint);
    if (fabIconTint != null) {
        setFabIconTint(fabIconTint);
    }

    timePickerAttrs.recycle();
}
 
开发者ID:philliphsu,项目名称:NumberPadTimePicker,代码行数:43,代码来源:NumberPadTimePickerBottomSheetComponent.java

示例15: onAttachedToWindow

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@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();
}
 
开发者ID:Alcatraz323,项目名称:MaterialOCR,代码行数:81,代码来源:FabSpeedDial.java


注:本文中的android.support.design.widget.FloatingActionButton.setBackgroundTintList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。