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


Java ColorStateList.valueOf方法代码示例

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


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

示例1: setChatFragmentFabColorToSharedPrefsValue

import android.content.res.ColorStateList; //导入方法依赖的package包/类
public static void setChatFragmentFabColorToSharedPrefsValue(AppCompatActivity activity)
{
    //Grab an instance of SharedPrefs if we haven't already
    if (mSharedPreferences == null)
    {
        mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
    }

    if (activity != null)
    {
        int initialColor = -1;
        if (mSharedPreferences.getBoolean("same_fab_color", false))
        {
            initialColor = mSharedPreferences.getInt("default_color", activity.getResources().getColor(R.color.colorPrimary));
        }
        else
        {
            initialColor = mSharedPreferences.getInt("fab_color", activity.getResources().getColor(R.color.colorAccent));
        }
        ColorStateList colorStateList = ColorStateList.valueOf(initialColor);
        tints(colorStateList, activity);
    }
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:24,代码来源:ChatFragFabsHue.java

示例2: tint

import android.content.res.ColorStateList; //导入方法依赖的package包/类
public static void tint(@NonNull ProgressBar progressBar, @ColorInt int color, boolean skipIndeterminate) {
    ColorStateList sl = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        progressBar.setProgressTintList(sl);
        progressBar.setSecondaryProgressTintList(sl);
        if (!skipIndeterminate)
            progressBar.setIndeterminateTintList(sl);
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (!skipIndeterminate && progressBar.getIndeterminateDrawable() != null)
            progressBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (progressBar.getProgressDrawable() != null)
            progressBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
开发者ID:jumaallan,项目名称:AndelaTrackChallenge,代码行数:19,代码来源:Easel.java

示例3: generateRippleMaskDrawable

import android.content.res.ColorStateList; //导入方法依赖的package包/类
/**
 * 边界被限制的Ripple, 默认状态是透明
 */
public static Drawable generateRippleMaskDrawable(int rippleColor) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return null;
    }
    RippleDrawable drawable = new RippleDrawable(ColorStateList.valueOf(rippleColor), null, new ColorDrawable(rippleColor));
    return drawable;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:11,代码来源:ResUtil.java

示例4: TextConfig

import android.content.res.ColorStateList; //导入方法依赖的package包/类
public TextConfig(TypedArray typedArray) {
    DEFAULT_SIZE = IconDotTextView.sDefaultTextSize;
    if (typedArray != null) {
        mSize = typedArray.getDimensionPixelSize(R.styleable.IconDotTextView_textSize, DEFAULT_SIZE);
        mColorStateList = typedArray.getColorStateList(R.styleable.IconDotTextView_textColor);
        if (mColorStateList == null) {
            mColorStateList = ColorStateList.valueOf(DEFAULT_COLOR);
        }
        mText = typedArray.getString(R.styleable.IconDotTextView_text);
    }
    init();
}
 
开发者ID:AssIstne,项目名称:IconDotTextView,代码行数:13,代码来源:TextConfig.java

示例5: getAdaptiveRippleDrawable

import android.content.res.ColorStateList; //导入方法依赖的package包/类
public static Drawable getAdaptiveRippleDrawable(
        int normalColor) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return new RippleDrawable(ColorStateList.valueOf(darker(normalColor)), getRippleMask(normalColor), null);
    } else {
        return getStateListDrawable(normalColor, darker(normalColor));
    }
}
 
开发者ID:jrvansuita,项目名称:MaterialAbout,代码行数:9,代码来源:RippleUtil.java

示例6: getSelectableBackgroundCompat

import android.content.res.ColorStateList; //导入方法依赖的package包/类
/**
 * Helper to get a custom selectable background with Ripple if device has at least Lollipop.
 *
 * @param normalColor  the color in normal state
 * @param pressedColor the pressed color
 * @param rippleColor  the color of the ripple
 * @return the RippleDrawable with StateListDrawable if at least Lollipop, the normal
 * StateListDrawable otherwise
 * @since 5.0.0-b7 Created
 * <br/>5.0.0-rc1 RippleColor becomes the 3rd parameter
 */
public static Drawable getSelectableBackgroundCompat(@ColorInt int normalColor,
													 @ColorInt int pressedColor,
													 @ColorInt int rippleColor) {
	if (Utils.hasLollipop()) {
		return new RippleDrawable(ColorStateList.valueOf(rippleColor),
				getStateListDrawable(normalColor, pressedColor),
				getRippleMask(normalColor));
	} else {
		return getStateListDrawable(normalColor, pressedColor);
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:DrawableUtils.java

示例7: setBorderColor

import android.content.res.ColorStateList; //导入方法依赖的package包/类
public void setBorderColor(ColorStateList colors) {
    if (mBorderColor.equals(colors)) {
        return;
    }

    mBorderColor = (colors != null) ? colors : ColorStateList
                   .valueOf(DEFAULT_BORDER_COLOR);
    updateDrawable();
    if (mBorderWidth > 0) {
        invalidate();
    }
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:13,代码来源:SelectableRoundedImageView.java

示例8: onCreate

import android.content.res.ColorStateList; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /**
     * Tint the spinner the primary theme color
     */
    ProgressBar progressBar = (ProgressBar) findViewById(android.R.id.progress);

    int color = ContextCompat.getColor(getContext(), R.color.kOrange);
    ColorStateList colorStateList = ColorStateList.valueOf(color);
    DrawableCompat.setTintList(progressBar.getIndeterminateDrawable(), colorStateList);
}
 
开发者ID:KwalaGroup,项目名称:Android-Client,代码行数:14,代码来源:KwalaProgressDialog.java

示例9: setBorderColor

import android.content.res.ColorStateList; //导入方法依赖的package包/类
public void setBorderColor(ColorStateList colors) {
  if (mBorderColor.equals(colors)) { return; }

  mBorderColor =
      (colors != null) ? colors : ColorStateList.valueOf(RoundedDrawable.DEFAULT_BORDER_COLOR);
  updateDrawableAttrs();
  updateBackgroundDrawableAttrs(false);
  if (mBorderWidth > 0) {
    invalidate();
  }
}
 
开发者ID:weimin96,项目名称:shareNote,代码行数:12,代码来源:RoundedImageView.java

示例10: setChipBackgroundColor

import android.content.res.ColorStateList; //导入方法依赖的package包/类
public void setChipBackgroundColor(@ColorInt int color) {
    this.backgroundColor = ColorStateList.valueOf(color);
    getChildAt(0).getBackground().setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
}
 
开发者ID:tylersuehr7,项目名称:chips-input-layout,代码行数:5,代码来源:ChipView.java

示例11: setMetTextColor

import android.content.res.ColorStateList; //导入方法依赖的package包/类
/**
 * Same function as {@link #setTextColor(int)}. (Directly overriding the built-in one could cause some error, so use this method instead.)
 */
public void setMetTextColor(int color) {
  textColorStateList = ColorStateList.valueOf(color);
  resetTextColor();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:MaterialMultiAutoCompleteTextView.java

示例12: setBorderColor

import android.content.res.ColorStateList; //导入方法依赖的package包/类
public RoundedDrawable setBorderColor(ColorStateList colors) {
	mBorderColor = colors != null ? colors : ColorStateList.valueOf(0);
	mBorderPaint.setColor(mBorderColor.getColorForState(getState(), DEFAULT_BORDER_COLOR));
	return this;
}
 
开发者ID:fahmisdk6,项目名称:AvatarView,代码行数:6,代码来源:RoundedDrawable.java

示例13: SmartTabLayout

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

  // Disable the Scroll Bar
  setHorizontalScrollBarEnabled(false);

  final DisplayMetrics dm = getResources().getDisplayMetrics();
  final float density = dm.density;

  int tabBackgroundResId = NO_ID;
  boolean textAllCaps = TAB_VIEW_TEXT_ALL_CAPS;
  ColorStateList textColors;
  float textSize = TypedValue.applyDimension(
      TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP, dm);
  int textHorizontalPadding = (int) (TAB_VIEW_PADDING_DIPS * density);
  int textMinWidth = (int) (TAB_VIEW_TEXT_MIN_WIDTH * density);
  boolean distributeEvenly = DEFAULT_DISTRIBUTE_EVENLY;
  int customTabLayoutId = NO_ID;
  int customTabTextViewId = NO_ID;
  boolean clickable = TAB_CLICKABLE;
  int titleOffset = (int) (TITLE_OFFSET_DIPS * density);

  TypedArray a = context.obtainStyledAttributes(
      attrs, R.styleable.stl_SmartTabLayout, defStyle, 0);
  tabBackgroundResId = a.getResourceId(
      R.styleable.stl_SmartTabLayout_stl_defaultTabBackground, tabBackgroundResId);
  textAllCaps = a.getBoolean(
      R.styleable.stl_SmartTabLayout_stl_defaultTabTextAllCaps, textAllCaps);
  textColors = a.getColorStateList(
      R.styleable.stl_SmartTabLayout_stl_defaultTabTextColor);
  textSize = a.getDimension(
      R.styleable.stl_SmartTabLayout_stl_defaultTabTextSize, textSize);
  textHorizontalPadding = a.getDimensionPixelSize(
      R.styleable.stl_SmartTabLayout_stl_defaultTabTextHorizontalPadding, textHorizontalPadding);
  textMinWidth = a.getDimensionPixelSize(
      R.styleable.stl_SmartTabLayout_stl_defaultTabTextMinWidth, textMinWidth);
  customTabLayoutId = a.getResourceId(
      R.styleable.stl_SmartTabLayout_stl_customTabTextLayoutId, customTabLayoutId);
  customTabTextViewId = a.getResourceId(
      R.styleable.stl_SmartTabLayout_stl_customTabTextViewId, customTabTextViewId);
  distributeEvenly = a.getBoolean(
      R.styleable.stl_SmartTabLayout_stl_distributeEvenly, distributeEvenly);
  clickable = a.getBoolean(
      R.styleable.stl_SmartTabLayout_stl_clickable, clickable);
  titleOffset = a.getLayoutDimension(
      R.styleable.stl_SmartTabLayout_stl_titleOffset, titleOffset);
  a.recycle();

  this.titleOffset = titleOffset;
  this.tabViewBackgroundResId = tabBackgroundResId;
  this.tabViewTextAllCaps = textAllCaps;
  this.tabViewTextColors = (textColors != null)
      ? textColors
      : ColorStateList.valueOf(TAB_VIEW_TEXT_COLOR);
  this.tabViewTextSize = textSize;
  this.tabViewTextHorizontalPadding = textHorizontalPadding;
  this.tabViewTextMinWidth = textMinWidth;
  this.internalTabClickListener = clickable ? new InternalTabClickListener() : null;
  this.distributeEvenly = distributeEvenly;

  if (customTabLayoutId != NO_ID) {
    setCustomTabView(customTabLayoutId, customTabTextViewId);
  }

  this.tabStrip = new SmartTabStrip(context, attrs);

  if (distributeEvenly && tabStrip.isIndicatorAlwaysInCenter()) {
    throw new UnsupportedOperationException(
        "'distributeEvenly' and 'indicatorAlwaysInCenter' both use does not support");
  }

  // Make sure that the Tab Strips fills this View
  setFillViewport(!tabStrip.isIndicatorAlwaysInCenter());

  addView(tabStrip, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

}
 
开发者ID:devzwy,项目名称:KUtils,代码行数:78,代码来源:SmartTabLayout.java

示例14: createBackgroundTintColors

import android.content.res.ColorStateList; //导入方法依赖的package包/类
/**
 */
@Nullable
@Override
ColorStateList createBackgroundTintColors(int tintColor) {
	return tintColor != Color.TRANSPARENT ? ColorStateList.valueOf(tintColor) : null;
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:8,代码来源:FlatButton.java

示例15: Config

import android.content.res.ColorStateList; //导入方法依赖的package包/类
protected Config(Context context) {
    int colorAccent = ColorUtils.getThemeAttrColor(context, R.attr.colorAccent);
    mBackgroundColorStateList = ColorStateList.valueOf(colorAccent);
    mTextBackgroundDrawable = R.drawable.qav_text_background;
    mTextColor = Color.WHITE;
}
 
开发者ID:ovenbits,项目名称:QuickActionView,代码行数:7,代码来源:Action.java


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