當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。