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


Java TypedArray.getColorStateList方法代码示例

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


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

示例1: resolveActionTextColorStateList

import android.content.res.TypedArray; //导入方法依赖的package包/类
public static ColorStateList resolveActionTextColorStateList(
        Context context, @AttrRes int colorAttr, ColorStateList fallback) {
    TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{colorAttr});
    try {
        final TypedValue value = a.peekValue(0);
        if (value == null) {
            return fallback;
        }
        if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
            return getActionTextStateList(context, value.data);
        } else {
            final ColorStateList stateList = a.getColorStateList(0);
            if (stateList != null) {
                return stateList;
            } else {
                return fallback;
            }
        }
    } finally {
        a.recycle();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:DialogUtils.java

示例2: processTintValues

import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
 * Called from the constructor to process tint values for this view.
 *
 * @param context    The context passed to constructor.
 * @param typedArray TypedArray obtained for styleable attributes specific for this view.
 */
@SuppressWarnings("All")
private void processTintValues(Context context, TypedArray typedArray) {
	this.ensureTintInfo();
	if (typedArray.hasValue(R.styleable.Ui_MonthView_uiIndicatorTint)) {
		mTintInfo.tintList = typedArray.getColorStateList(R.styleable.Ui_MonthView_uiIndicatorTint);
	}
	mTintInfo.tintMode = TintManager.parseTintMode(
			typedArray.getInt(R.styleable.Ui_MonthView_uiIndicatorTintMode, 0),
			PorterDuff.Mode.SRC_IN
	);
	// If there is no tint mode specified within style/xml do not tint at all.
	if (mTintInfo.tintMode == null) mTintInfo.tintList = null;
	mTintInfo.hasTintList = mTintInfo.tintList != null;
	mTintInfo.hasTintMode = mTintInfo.tintMode != null;
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:22,代码来源:MonthView.java

示例3: onProcessTintAttributes

import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
 */
@Override
@SuppressWarnings("ResourceType")
void onProcessTintAttributes(Context context, TypedArray tintAttributes, int tintColor) {
	super.onProcessTintAttributes(context, tintAttributes, tintColor);
	if (UiConfig.MATERIALIZED) {
		if (tintAttributes.hasValue(R.styleable.Ui_HorizontalScrollView_uiBackgroundTint)) {
			setBackgroundTintList(tintAttributes.getColorStateList(R.styleable.Ui_HorizontalScrollView_uiBackgroundTint));
		}
		if (tintAttributes.hasValue(R.styleable.Ui_HorizontalScrollView_uiBackgroundTintMode)) {
			setBackgroundTintMode(TintManager.parseTintMode(
					tintAttributes.getInt(R.styleable.Ui_HorizontalScrollView_uiBackgroundTintMode, 0),
					PorterDuff.Mode.SRC_IN
			));
		}
	} else {
		if (tintAttributes.hasValue(R.styleable.Ui_HorizontalScrollView_uiBackgroundTint)) {
			mTintInfo.backgroundTintList = tintAttributes.getColorStateList(R.styleable.Ui_HorizontalScrollView_uiBackgroundTint);
		}
		mTintInfo.backgroundTintMode = TintManager.parseTintMode(
				tintAttributes.getInt(R.styleable.Ui_HorizontalScrollView_uiBackgroundTintMode, 0),
				mTintInfo.backgroundTintList != null ? PorterDuff.Mode.SRC_IN : null
		);
	}
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:27,代码来源:HorizontalScrollViewWidget.java

示例4: onProcessTintAttributes

import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
 */
@Override
@SuppressWarnings("ResourceType")
void onProcessTintAttributes(Context context, TypedArray tintAttributes, int tintColor) {
	if (UiConfig.MATERIALIZED) {
		if (tintAttributes.hasValue(R.styleable.Ui_View_uiBackgroundTint)) {
			setBackgroundTintList(tintAttributes.getColorStateList(R.styleable.Ui_View_uiBackgroundTint));
		}
		if (tintAttributes.hasValue(R.styleable.Ui_View_uiBackgroundTintMode)) {
			setBackgroundTintMode(TintManager.parseTintMode(
					tintAttributes.getInt(R.styleable.Ui_View_uiBackgroundTintMode, 0),
					PorterDuff.Mode.SRC_IN
			));
		}
	} else {
		if (tintAttributes.hasValue(R.styleable.Ui_View_uiBackgroundTint)) {
			mTintInfo.backgroundTintList = tintAttributes.getColorStateList(R.styleable.Ui_View_uiBackgroundTint);
		}
		mTintInfo.backgroundTintMode = TintManager.parseTintMode(
				tintAttributes.getInteger(R.styleable.Ui_View_uiBackgroundTintMode, 0),
				mTintInfo.backgroundTintList != null ? PorterDuff.Mode.SRC_IN : null
		);
	}
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:26,代码来源:ViewWidget.java

示例5: initAttrs

import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
     * 获取 xml 中的属性
     *
     * @param context
     * @param attrs
     */
    private void initAttrs(Context context, AttributeSet attrs) {
        if (attrs == null) {
//            LogUtils.d("不是从xml 中加载的");
            return;
        }
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UIBottomBarItem);
        /** 1、图片资源相关 */
        mIconNormal = a.getResourceId(R.styleable.UIBottomBarItem_ws_item_icon_nomal, DEFAULT_RES_ID);
        mIconSelected = a.getResourceId(R.styleable.UIBottomBarItem_ws_item_icon_sel, DEFAULT_RES_ID);
        mIconDrawable = a.getDrawable(R.styleable.UIBottomBarItem_ws_item_icon);

        /** 2、标题相关*/
        mTextColorNormal = a.getColor(R.styleable.UIBottomBarItem_ws_item_text_nomal_color, DEFAULT_RES_ID);
        mTextColorSelected = a.getColor(R.styleable.UIBottomBarItem_ws_item_text_sel_color, DEFAULT_RES_ID);
        mTextColorList = a.getColorStateList(R.styleable.UIBottomBarItem_ws_item_text_color);

        mText = a.getString(R.styleable.UIBottomBarItem_ws_item_text);
        mTextSize = a.getDimensionPixelSize(R.styleable.UIBottomBarItem_ws_item_text_size,
                DEFAULT_TITLE_TEXT_SIZE);

        a.recycle();
    }
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:29,代码来源:UIBottomBarItem.java

示例6: init

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.SimpleMarqueeView, 0, 0);
    textColor = a.getColorStateList(R.styleable.SimpleMarqueeView_smvTextColor);
    if (a.hasValue(R.styleable.SimpleMarqueeView_smvTextSize)) {
        textSize = a.getDimension(R.styleable.SimpleMarqueeView_smvTextSize, textSize);
        textSize = Util.px2Sp(getContext(), textSize);
    }
    smvTextGravity = a.getInt(R.styleable.SimpleMarqueeView_smvTextGravity, smvTextGravity);
    a.recycle();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:SimpleMarqueeView.java

示例7: FloatingActionButton

import android.content.res.TypedArray; //导入方法依赖的package包/类
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    // ThemeUtils.checkAppCompatTheme(context);

        TypedArray a = context.obtainStyledAttributes(attrs,
                R.styleable.FloatingActionButton, defStyleAttr,
            R.style.Widget_Design_FloatingActionButton);
    mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_android_backgroundTint);
    mBackgroundTintMode =
        ViewUtils.parseTintMode(
            a.getInt(R.styleable.FloatingActionButton_android_backgroundTintMode, -1), null);
    mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0);
    mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, SIZE_AUTO);
    mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0);
    final float elevation = a.getDimension(R.styleable.FloatingActionButton_android_elevation, 0f);
    final float pressedTranslationZ =
        a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0f);
    mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false);
    a.recycle();

/*
    mImageHelper = new AppCompatImageHelper(this);
    mImageHelper.loadFromAttributes(attrs, defStyleAttr);
*/

    mMaxImageSize = (int) getResources().getDimension(R.dimen.design_fab_image_size);

        getImpl().setBackgroundDrawable(mBackgroundTint, mBackgroundTintMode,
                mRippleColor, mBorderWidth);
    getImpl().setElevation(elevation);
    getImpl().setPressedTranslationZ(pressedTranslationZ);
  }
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:34,代码来源:FloatingActionButton.java

示例8: obtainTabTitleTextColor

import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
 * Obtains the text color of a tab's title from a specific typed array.
 *
 * @param typedArray
 *         The typed array, the text color should be obtained from, as an instance of the class
 *         {@link TypedArray}. The typed array may not be null
 */
private void obtainTabTitleTextColor(@NonNull final TypedArray typedArray) {
    ColorStateList colorStateList =
            typedArray.getColorStateList(R.styleable.TabSwitcher_tabTitleTextColor);

    if (colorStateList != null) {
        setTabTitleTextColor(colorStateList);
    }
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:16,代码来源:TabSwitcher.java

示例9: fromAttributeSet

import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
 * 根据 AttributeSet
 * @param context
 * @param attrs
 * @param defStyleAttr
 * @return
 */
public static QMUIRoundButtonDrawable fromAttributeSet(Context context, AttributeSet attrs, int defStyleAttr) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.QMUIRoundButton, defStyleAttr, 0);
    ColorStateList colorBg = typedArray.getColorStateList(R.styleable.QMUIRoundButton_qmui_backgroundColor);
    ColorStateList colorBorder = typedArray.getColorStateList(R.styleable.QMUIRoundButton_qmui_borderColor);
    int borderWidth = typedArray.getDimensionPixelSize(R.styleable.QMUIRoundButton_qmui_borderWidth, 0);
    boolean isRadiusAdjustBounds = typedArray.getBoolean(R.styleable.QMUIRoundButton_qmui_isRadiusAdjustBounds, false);
    int mRadius = typedArray.getDimensionPixelSize(R.styleable.QMUIRoundButton_qmui_radius, 0);
    int mRadiusTopLeft = typedArray.getDimensionPixelSize(R.styleable.QMUIRoundButton_qmui_radiusTopLeft, 0);
    int mRadiusTopRight = typedArray.getDimensionPixelSize(R.styleable.QMUIRoundButton_qmui_radiusTopRight, 0);
    int mRadiusBottomLeft = typedArray.getDimensionPixelSize(R.styleable.QMUIRoundButton_qmui_radiusBottomLeft, 0);
    int mRadiusBottomRight = typedArray.getDimensionPixelSize(R.styleable.QMUIRoundButton_qmui_radiusBottomRight, 0);
    typedArray.recycle();

    QMUIRoundButtonDrawable bg = new QMUIRoundButtonDrawable();
    bg.setBgData(colorBg);
    bg.setStrokeData(borderWidth, colorBorder);
    if (mRadiusTopLeft > 0 || mRadiusTopRight > 0 || mRadiusBottomLeft > 0 || mRadiusBottomRight > 0) {
        float[] radii = new float[]{
                mRadiusTopLeft, mRadiusTopLeft,
                mRadiusTopRight, mRadiusTopRight,
                mRadiusBottomRight, mRadiusBottomRight,
                mRadiusBottomLeft, mRadiusBottomLeft
        };
        bg.setCornerRadii(radii);
        isRadiusAdjustBounds = false;
    } else {
        bg.setCornerRadius(mRadius);
        if(mRadius > 0){
            isRadiusAdjustBounds = false;
        }
    }
    bg.setIsRadiusAdjustBounds(isRadiusAdjustBounds);
    return bg;
}
 
开发者ID:coopese,项目名称:qmui,代码行数:42,代码来源:QMUIRoundButtonDrawable.java

示例10: HelperTextInputLayout

import android.content.res.TypedArray; //导入方法依赖的package包/类
public HelperTextInputLayout(Context _context, AttributeSet _attrs) {
	super(_context, _attrs);

	final TypedArray a = getContext().obtainStyledAttributes(
			_attrs,
			R.styleable.HelperTextInputLayout,0,0);
	try {
		mHelperTextColor = a.getColorStateList(R.styleable.HelperTextInputLayout_helperTextColor);
		mHelperText = a.getText(R.styleable.HelperTextInputLayout_helperText);
	} finally {
		a.recycle();
	}
}
 
开发者ID:TrustWallet,项目名称:trust-wallet-android,代码行数:14,代码来源:HelperTextInputLayout.java

示例11: onProcessTintAttributes

import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
 */
@Override
@SuppressWarnings("ResourceType")
void onProcessTintAttributes(Context context, TypedArray tintAttributes, int tintColor) {
	if (UiConfig.MATERIALIZED) {
		if (tintAttributes.hasValue(R.styleable.Ui_ImageView_uiTint)) {
			setImageTintList(tintAttributes.getColorStateList(R.styleable.Ui_ImageView_uiTint));
		}
		if (tintAttributes.hasValue(R.styleable.Ui_ImageView_uiBackgroundTint)) {
			setBackgroundTintList(tintAttributes.getColorStateList(R.styleable.Ui_ImageView_uiBackgroundTint));
		}
		if (tintAttributes.hasValue(R.styleable.Ui_ImageView_uiTintMode)) {
			setImageTintMode(TintManager.parseTintMode(
					tintAttributes.getInt(R.styleable.Ui_ImageView_uiTintMode, 0),
					mTintInfo.tintList != null ? PorterDuff.Mode.SRC_IN : null
			));
		}
		if (tintAttributes.hasValue(R.styleable.Ui_ImageView_uiBackgroundTintMode)) {
			setBackgroundTintMode(TintManager.parseTintMode(
					tintAttributes.getInteger(R.styleable.Ui_ImageView_uiBackgroundTintMode, 0),
					PorterDuff.Mode.SRC_IN
			));
		}
	} else {
		if (tintAttributes.hasValue(R.styleable.Ui_ImageView_uiTint)) {
			mTintInfo.tintList = tintAttributes.getColorStateList(R.styleable.Ui_ImageView_uiTint);
		}
		if (tintAttributes.hasValue(R.styleable.Ui_ImageView_uiBackgroundTint)) {
			mTintInfo.backgroundTintList = tintAttributes.getColorStateList(R.styleable.Ui_ImageView_uiBackgroundTint);
		}
		mTintInfo.tintMode = TintManager.parseTintMode(
				tintAttributes.getInt(R.styleable.Ui_ImageView_uiTintMode, 0),
				mTintInfo.tintList != null ? PorterDuff.Mode.SRC_IN : null
		);
		mTintInfo.backgroundTintMode = TintManager.parseTintMode(
				tintAttributes.getInteger(R.styleable.Ui_ImageView_uiBackgroundTintMode, 0),
				PorterDuff.Mode.SRC_IN
		);
	}
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:42,代码来源:ImageViewWidget.java

示例12: setExpandedTextAppearance

import android.content.res.TypedArray; //导入方法依赖的package包/类
void setExpandedTextAppearance(int resId) {
  TypedArray a =
      mView.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
  if (a.hasValue(R.styleable.TextAppearance_android_textColor)) {
    mExpandedTextColor =
        a.getColorStateList(R.styleable.TextAppearance_android_textColor);
  }
  if (a.hasValue(R.styleable.TextAppearance_android_textSize)) {
    mExpandedTextSize =
        a.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize,
            (int) mExpandedTextSize);
  }
  mExpandedShadowColor =
      a.getInt(R.styleable.TextAppearance_android_shadowColor, 0);
  mExpandedShadowDx =
      a.getFloat(R.styleable.TextAppearance_android_shadowDx, 0);
  mExpandedShadowDy =
      a.getFloat(R.styleable.TextAppearance_android_shadowDy, 0);
  mExpandedShadowRadius =
      a.getFloat(R.styleable.TextAppearance_android_shadowRadius, 0);
  a.recycle();

  if (Build.VERSION.SDK_INT >= 16) {
    mExpandedTypeface = readFontFamilyTypeface(resId);
  }

  recalculate();
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:29,代码来源:CollapsingTextHelper.java

示例13: ActiveItemImageView

import android.content.res.TypedArray; //导入方法依赖的package包/类
public ActiveItemImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.cornerRadius = 0.0f;
    this.borderWidth = 0.0f;
    this.borderColor = ColorStateList.valueOf(-16777216);
    this.isOval = false;
    this.mutateBackground = false;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RoundedImageView, defStyle, 0);
    int index = a.getInt(R.styleable.RoundedImageView_android_scaleType, -1);
    if (index >= 0) {
        setScaleType(SCALE_TYPES[index]);
    } else {
        setScaleType(ScaleType.FIT_CENTER);
    }
    this.cornerRadius = (float) a.getDimensionPixelSize(R.styleable.RoundedImageView_riv_corner_radius, -1);
    this.borderWidth = (float) a.getDimensionPixelSize(R.styleable.RoundedImageView_riv_border_width, -1);
    if (this.cornerRadius < 0.0f) {
        this.cornerRadius = 0.0f;
    }
    if (this.borderWidth < 0.0f) {
        this.borderWidth = 0.0f;
    }
    this.borderColor = a.getColorStateList(R.styleable.RoundedImageView_riv_border_color);
    if (this.borderColor == null) {
        this.borderColor = ColorStateList.valueOf(-16777216);
    }
    this.mutateBackground = a.getBoolean(R.styleable.RoundedImageView_riv_mutate_background, false);
    this.isOval = a.getBoolean(R.styleable.RoundedImageView_riv_oval, false);
    updateDrawableAttrs();
    updateBackgroundDrawableAttrs(true);
    a.recycle();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:33,代码来源:ActiveItemImageView.java

示例14: RoundedImageView

import android.content.res.TypedArray; //导入方法依赖的package包/类
public RoundedImageView(Context context, AttributeSet attrs, int defStyle) {
    int i;
    super(context, attrs, defStyle);
    this.mCornerRadii = new float[]{0.0f, 0.0f, 0.0f, 0.0f};
    this.mBorderColor = ColorStateList.valueOf(-16777216);
    this.mBorderWidth = 0.0f;
    this.mColorFilter = null;
    this.mColorMod = false;
    this.mHasColorFilter = false;
    this.mIsOval = false;
    this.mMutateBackground = false;
    this.mScaleType = ScaleType.FIT_CENTER;
    this.mTileModeX = DEFAULT_TILE_MODE;
    this.mTileModeY = DEFAULT_TILE_MODE;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RoundedImageView,
            defStyle, 0);
    int index = a.getInt(R.styleable.RoundedImageView_android_scaleType, -1);
    if (index >= 0) {
        setScaleType(SCALE_TYPES[index]);
    } else {
        setScaleType(ScaleType.FIT_CENTER);
    }
    float cornerRadiusOverride = (float) a.getDimensionPixelSize(R.styleable
            .RoundedImageView_riv_corner_radius, -1);
    this.mCornerRadii[0] = (float) a.getDimensionPixelSize(R.styleable
            .RoundedImageView_riv_corner_radius_top_left, -1);
    this.mCornerRadii[1] = (float) a.getDimensionPixelSize(R.styleable
            .RoundedImageView_riv_corner_radius_top_right, -1);
    this.mCornerRadii[2] = (float) a.getDimensionPixelSize(R.styleable
            .RoundedImageView_riv_corner_radius_bottom_right, -1);
    this.mCornerRadii[3] = (float) a.getDimensionPixelSize(R.styleable
            .RoundedImageView_riv_corner_radius_bottom_left, -1);
    boolean any = false;
    int len = this.mCornerRadii.length;
    for (i = 0; i < len; i++) {
        if (this.mCornerRadii[i] < 0.0f) {
            this.mCornerRadii[i] = 0.0f;
        } else {
            any = true;
        }
    }
    if (!any) {
        if (cornerRadiusOverride < 0.0f) {
            cornerRadiusOverride = 0.0f;
        }
        len = this.mCornerRadii.length;
        for (i = 0; i < len; i++) {
            this.mCornerRadii[i] = cornerRadiusOverride;
        }
    }
    this.mBorderWidth = (float) a.getDimensionPixelSize(R.styleable
            .RoundedImageView_riv_border_width, -1);
    if (this.mBorderWidth < 0.0f) {
        this.mBorderWidth = 0.0f;
    }
    this.mBorderColor = a.getColorStateList(R.styleable.RoundedImageView_riv_border_color);
    if (this.mBorderColor == null) {
        this.mBorderColor = ColorStateList.valueOf(-16777216);
    }
    this.mMutateBackground = a.getBoolean(R.styleable.RoundedImageView_riv_mutate_background,
            false);
    this.mIsOval = a.getBoolean(R.styleable.RoundedImageView_riv_oval, false);
    int tileMode = a.getInt(R.styleable.RoundedImageView_riv_tile_mode, -2);
    if (tileMode != -2) {
        setTileModeX(parseTileMode(tileMode));
        setTileModeY(parseTileMode(tileMode));
    }
    int tileModeX = a.getInt(R.styleable.RoundedImageView_riv_tile_mode_x, -2);
    if (tileModeX != -2) {
        setTileModeX(parseTileMode(tileModeX));
    }
    int tileModeY = a.getInt(R.styleable.RoundedImageView_riv_tile_mode_y, -2);
    if (tileModeY != -2) {
        setTileModeY(parseTileMode(tileModeY));
    }
    updateDrawableAttrs();
    updateBackgroundDrawableAttrs(true);
    a.recycle();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:80,代码来源:RoundedImageView.java

示例15: init

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
            R.anim.bottom_in);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
            R.anim.bottom_out);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
    // set default value if null same as for textview
    if (mLabelsTextColor == null) {
        mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
    }
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
    if (mIcon == null) {
        mIcon = getResources().getDrawable(R.drawable.ic_add_fab);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.RED);

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
        mUsingMenuLabel = true;
        mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
    }

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }

    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

    initBackgroundDimAnimation();
    createMenuButton();
    initMenuButtonAnimations(attr);

    attr.recycle();
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:66,代码来源:FloatingActionMenu.java


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