android.support.annotation.ColorRes Java Examples
The following examples show how to use
android.support.annotation.ColorRes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: DanDanPlayForAndroid Author: xyoye File: CommonUtils.java License: MIT License | 6 votes |
/** * 获取加透明度的资源颜色 */ @ColorInt public static int getResColor(@IntRange(from = 0, to = 255) int alpha, @ColorRes int colorId) { int color = getResColor(colorId); int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); return Color.argb(alpha, red, green, blue); }
Example #2
Source Project: timecat Author: triline3 File: TintManager.java License: Apache License 2.0 | 6 votes |
@Nullable public ColorStateList getColorStateList(@ColorRes int resId) { if (resId == 0) return null; final Context context = mContextRef.get(); if (context == null) return null; ColorStateList colorStateList = mCacheTintList != null ? mCacheTintList.get(resId) : null; if (colorStateList == null) { colorStateList = ColorStateListUtils.createColorStateList(context, resId); if (colorStateList != null) { if (mCacheTintList == null) { mCacheTintList = new SparseArray<>(); } mCacheTintList.append(resId, colorStateList); } } return colorStateList; }
Example #3
Source Project: Tok-Android Author: InsightIM File: ScreenUtils.java License: GNU General Public License v3.0 | 5 votes |
public static int getColor(@NonNull Context context, @ColorRes int id) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return context.getColor(id); } else { return context.getResources().getColor(id); } }
Example #4
Source Project: SimpleAdapterDemo Author: JustinRoom File: CompatResourceUtils.java License: Apache License 2.0 | 5 votes |
public static int getColor(@NonNull Context context, @ColorRes int resId){ int color; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M){ color = context.getResources().getColor(resId, context.getTheme()); } else { color = context.getResources().getColor(resId); } return color; }
Example #5
Source Project: PocketEOS-Android Author: OracleChain File: ImmersionBar.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * 解决布局与状态栏重叠问题,支持侧滑返回 * Fits system windows immersion bar. * * @param fits the fits * @param statusBarColorContentView the status bar color content view 状态栏颜色 * @param statusBarColorContentViewTransform the status bar color content view transform 状态栏变色后的颜色 * @param statusBarContentViewAlpha the status bar content view alpha 透明度 * @return the immersion bar */ public ImmersionBar fitsSystemWindows(boolean fits, @ColorRes int statusBarColorContentView , @ColorRes int statusBarColorContentViewTransform, @FloatRange(from = 0f, to = 1f) float statusBarContentViewAlpha) { mBarParams.fits = fits; mBarParams.statusBarColorContentView = ContextCompat.getColor(mActivity, statusBarColorContentView); mBarParams.statusBarColorContentViewTransform = ContextCompat.getColor(mActivity, statusBarColorContentViewTransform); mBarParams.statusBarContentViewAlpha = statusBarContentViewAlpha; mBarParams.statusBarColorContentView = ContextCompat.getColor(mActivity, statusBarColorContentView); mContentView.setBackgroundColor(ColorUtils.blendARGB(mBarParams.statusBarColorContentView, mBarParams.statusBarColorContentViewTransform, mBarParams.statusBarContentViewAlpha)); return this; }
Example #6
Source Project: timecat Author: triline3 File: TimeCatApp.java License: Apache License 2.0 | 5 votes |
@Override public int replaceColorById(Context context, @ColorRes int colorId) { if (ThemeManager.isDefaultTheme(context)) { return context.getResources().getColor(colorId); } String theme = getTheme(context); if (theme != null) { colorId = getThemeColorId(context, colorId, theme); } return context.getResources().getColor(colorId); }
Example #7
Source Project: styT Author: stytooldex File: TapTarget.java License: Apache License 2.0 | 5 votes |
@Nullable private Integer colorResOrInt(Context context, @Nullable Integer value, @ColorRes int resource) { if (resource != -1) { return ContextCompat.getColor(context, resource); } return value; }
Example #8
Source Project: PowerFileExplorer Author: PowerExplorer File: ColorPref.java License: GNU General Public License v3.0 | 5 votes |
@ColorRes private int getColorResAt(int position) { Integer item = getItem(position); if (item == null) { return usage.getDefaultColor(); } else { return item.intValue(); } }
Example #9
Source Project: timecat Author: triline3 File: TimeCatApp.java License: Apache License 2.0 | 5 votes |
private @ColorRes int getThemeColorId(Context context, int colorId, String theme) { switch (colorId) { case R.color.theme_color_primary: return context.getResources().getIdentifier(theme, "color", getPackageName()); case R.color.theme_color_primary_dark: return context.getResources().getIdentifier(theme + "_dark", "color", getPackageName()); case R.color.playbarProgressColor: return context.getResources().getIdentifier(theme + "_trans", "color", getPackageName()); } return colorId; }
Example #10
Source Project: timecat Author: triline3 File: AppCompatTextHelper.java License: Apache License 2.0 | 5 votes |
private void setTextColor(@ColorRes int resId) { if (mTextColorId != resId) { resetTextColorTintResource(resId); if (resId != 0) { setSupportTextColorTint(resId); } } }
Example #11
Source Project: OmniList Author: Shouheng88 File: PalmApp.java License: GNU Affero General Public License v3.0 | 5 votes |
public static @ColorInt int getColorCompact(@ColorRes int colorRes) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return PalmApp.getContext().getColor(colorRes); } else { return PalmApp.getContext().getResources().getColor(colorRes); } }
Example #12
Source Project: timecat Author: triline3 File: TintRadioButton.java License: Apache License 2.0 | 4 votes |
@Override public void setTextColorById(@ColorRes int colorId) { if (mTextHelper != null) { mTextHelper.setTextColorById(colorId); } }
Example #13
Source Project: SmartLoadingView Author: lihangleo2 File: CircleImageView.java License: MIT License | 4 votes |
public void setBorderColorResource(@ColorRes int borderColorRes) { setBorderColor(getContext().getResources().getColor(borderColorRes)); }
Example #14
Source Project: Dual-color-Polyline-Animation Author: tintinscorpion File: MapAnimator.java License: MIT License | 4 votes |
public void setSecondaryLineColor(@ColorRes int color) { GREY = color; }
Example #15
Source Project: input-samples Author: android File: NavigationItem.java License: Apache License 2.0 | 4 votes |
public NavigationItem(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationItem, defStyleAttr, defStyleRes); int activityMinSdk = typedArray.getInteger(R.styleable.NavigationItem_minSdk, 26); // TODO: Remove BuildCompat.isAtLeastP() check when API 28 is finalized. int deviceMinSdk = BuildCompat.isAtLeastP() ? 28 : Build.VERSION.SDK_INT; if (deviceMinSdk < activityMinSdk) { // If device's SDK is lower than the minSdk specified by the NavigationItem, hide it. setVisibility(View.GONE); return; } String labelText = typedArray.getString(R.styleable.NavigationItem_labelText); String infoText = typedArray.getString(R.styleable.NavigationItem_infoText); Drawable logoDrawable = typedArray.getDrawable(R.styleable.NavigationItem_itemLogo); @ColorRes int colorRes = typedArray.getResourceId(R.styleable.NavigationItem_imageColor, 0); String launchingActivityName = typedArray.getString(R.styleable.NavigationItem_destinationActivityName); int imageColor = ContextCompat.getColor(getContext(), colorRes); typedArray.recycle(); View rootView = LayoutInflater.from(context).inflate(R.layout.navigation_item, this); TextView buttonLabel = rootView.findViewById(R.id.buttonLabel); buttonLabel.setText(labelText); if (logoDrawable != null) { Drawable mutatedLogoDrawable = logoDrawable.mutate(); mutatedLogoDrawable.setColorFilter(imageColor, PorterDuff.Mode.SRC_IN); buttonLabel.setCompoundDrawablesRelativeWithIntrinsicBounds(mutatedLogoDrawable, null, null, null); } InfoButton infoButton = rootView.findViewById(R.id.infoButton); infoButton.setInfoText(infoText); infoButton.setColorFilter(imageColor); CardView outerView = rootView.findViewById(R.id.cardView); outerView.setOnClickListener((view) -> { if (launchingActivityName != null) { Intent intent = new Intent(); intent.setClassName(getContext().getPackageName(), launchingActivityName); context.startActivity(intent); } else { Log.w(TAG, "Launching Activity name not set."); } }); }
Example #16
Source Project: Android-utils Author: Shouheng88 File: ResUtils.java License: Apache License 2.0 | 4 votes |
@ColorInt public static int getColor(@ColorRes int id) { return UtilsApp.getApp().getResources().getColor(id); }
Example #17
Source Project: FeedbackDialog Author: shivasurya File: FeedBackDialog.java License: Apache License 2.0 | 4 votes |
public FeedBackDialog setBackgroundColor(@ColorRes int mBackgroundColor) { this.mBackgroundColor = mBackgroundColor; return this; }
Example #18
Source Project: FeedbackDialog Author: shivasurya File: FeedBackDialog.java License: Apache License 2.0 | 4 votes |
public FeedBackDialog setIconColor(@ColorRes int mIconColor) { this.mIconColor = mIconColor; return this; }
Example #19
Source Project: OmniList Author: Shouheng88 File: Colorful.java License: GNU Affero General Public License v3.0 | 4 votes |
ThemeColor(@ColorRes int colorRes, @ColorRes int darkColorRes, String identifyName, String displayName) { this.colorRes = colorRes; this.darkColorRes = darkColorRes; this.identifyName = identifyName; this.displayName = displayName; }
Example #20
Source Project: Hify Author: lvamsavarthan File: SwipeConfiguration.java License: MIT License | 4 votes |
public Builder setLeftBackgroundColorResource(@ColorRes int resId) { mLeftBackgroundColor = mContext.getResources().getColor(resId); return this; }
Example #21
Source Project: Hify Author: lvamsavarthan File: SwipeConfiguration.java License: MIT License | 4 votes |
public Builder setRightBackgroundColorResource(@ColorRes int resId) { mRightBackgroundColor = mContext.getResources().getColor(resId); return this; }
Example #22
Source Project: relight Author: ittianyu File: SwipeRefreshWidget.java License: Apache License 2.0 | 4 votes |
public SwipeRefreshWidget colorSchemeResources(@ColorRes int... colorResIds) { view.setColorSchemeResources(colorResIds); return self(); }
Example #23
Source Project: ToDoList Author: LeeLulin File: CircleImageView.java License: Apache License 2.0 | 4 votes |
/** * @deprecated Use {@link #setBorderColor(int)} instead */ @Deprecated public void setBorderColorResource(@ColorRes int borderColorRes) { setBorderColor(getContext().getResources().getColor(borderColorRes)); }
Example #24
Source Project: relight Author: ittianyu File: MaterialButtonWidget.java License: Apache License 2.0 | 4 votes |
public MaterialButtonWidget iconTintResource(@ColorRes int iconTintResourceId) { view.setIconTintResource(iconTintResourceId); return self(); }
Example #25
Source Project: imsdk-android Author: qunarcorp File: BaseBuilder.java License: MIT License | 4 votes |
public H setTextColorRes(@ColorRes int color, @NonNull Context context){ mProgress.setTextColor(context.getResources().getColor(color)); return (H) this; }
Example #26
Source Project: imsdk-android Author: qunarcorp File: CircleProgress.java License: MIT License | 4 votes |
public Builder setBottomColorRes(@ColorRes int ColorRes, Context context) { mProgress.mCircleBottomColor = context.getResources().getColor(ColorRes); return this; }
Example #27
Source Project: imsdk-android Author: qunarcorp File: CircleProgress.java License: MIT License | 4 votes |
public Builder setProgressColorRes(@ColorRes int ColorRes, Context context) { mProgress.mCircleProgressColor = context.getResources().getColor(ColorRes); return this; }
Example #28
Source Project: kAndroid Author: 1067899750 File: BaseRateView.java License: Apache License 2.0 | 4 votes |
public int getColor(@ColorRes int resId) { return ContextCompat.getColor(getContext(), resId); }
Example #29
Source Project: DanDanPlayForAndroid Author: xyoye File: CommonPlayerUtils.java License: MIT License | 4 votes |
@ColorInt public static int getResColor(Context context, @ColorRes int colorId){ return ContextCompat.getColor(context, colorId); }
Example #30
Source Project: kAndroid Author: 1067899750 File: BaseLineRateView.java License: Apache License 2.0 | 4 votes |
public int getColor(@ColorRes int resId) { return ContextCompat.getColor(getContext(), resId); }