FloatingActionButtonImpl.java 文件源码

java
阅读 35 收藏 0 点赞 0 评论 0

项目:cwac-crossport 作者:
void setBackgroundDrawable(ColorStateList backgroundTint,
        PorterDuff.Mode backgroundTintMode, int rippleColor, int borderWidth) {
    // Now we need to tint the original background with the tint, using
    // an InsetDrawable if we have a border width
    mShapeDrawable = DrawableCompat.wrap(createShapeDrawable());
    DrawableCompat.setTintList(mShapeDrawable, backgroundTint);
    if (backgroundTintMode != null) {
        DrawableCompat.setTintMode(mShapeDrawable, backgroundTintMode);
    }

    // Now we created a mask Drawable which will be used for touch feedback.
    GradientDrawable touchFeedbackShape = createShapeDrawable();

    // We'll now wrap that touch feedback mask drawable with a ColorStateList. We do not need
    // to inset for any border here as LayerDrawable will nest the padding for us
    mRippleDrawable = DrawableCompat.wrap(touchFeedbackShape);
    DrawableCompat.setTintList(mRippleDrawable, createColorStateList(rippleColor));

    final Drawable[] layers;
    if (borderWidth > 0) {
        mBorderDrawable = createBorderDrawable(borderWidth, backgroundTint);
        layers = new Drawable[] {mBorderDrawable, mShapeDrawable, mRippleDrawable};
    } else {
        mBorderDrawable = null;
        layers = new Drawable[] {mShapeDrawable, mRippleDrawable};
    }

    mContentBackground = new LayerDrawable(layers);

    mShadowDrawable = new ShadowDrawableWrapper(
            mView.getContext(),
            mContentBackground,
            mShadowViewDelegate.getRadius(),
            mElevation,
            mElevation + mPressedTranslationZ);
    mShadowDrawable.setAddPaddingForCorners(false);
    mShadowViewDelegate.setBackgroundDrawable(mShadowDrawable);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号