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 File: CommonUtils.java From DanDanPlayForAndroid with 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 File: TimeCatApp.java From timecat with 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 #3
Source File: ScreenUtils.java From Tok-Android with 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 File: TapTarget.java From styT with 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 #5
Source File: ColorPref.java From PowerFileExplorer with 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 #6
Source File: TimeCatApp.java From timecat with 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 #7
Source File: ImmersionBar.java From PocketEOS-Android with 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 #8
Source File: PalmApp.java From OmniList with 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 #9
Source File: TintManager.java From timecat with Apache License 2.0 | 5 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 #10
Source File: CompatResourceUtils.java From SimpleAdapterDemo with 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 #11
Source File: AppCompatTextHelper.java From timecat with Apache License 2.0 | 5 votes |
private void setTextColor(@ColorRes int resId) { if (mTextColorId != resId) { resetTextColorTintResource(resId); if (resId != 0) { setSupportTextColorTint(resId); } } }
Example #12
Source File: KSnack.java From KSnack with Apache License 2.0 | 4 votes |
public KSnack setTextColor(@NonNull @ColorRes int colorInt) { // Change text color. txtMessage.setTextColor(txtMessage.getContext().getResources().getColor(colorInt)); return this; }
Example #13
Source File: FinestWebView.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public Builder menuDropShadowColorRes(@ColorRes int colorRes) { this.menuDropShadowColor = ResourcesUtil.getColor(colorRes); return this; }
Example #14
Source File: ResourcesUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
@ColorInt public static int getColor(@ColorRes int colorRes) { return ContextUtil.getColor(colorRes); }
Example #15
Source File: ThemeUtils.java From timecat with Apache License 2.0 | 4 votes |
public static Drawable tintDrawableByColorId(Context context, Drawable drawable, @ColorRes int colorId) { if (drawable == null) return null; if (colorId <= 0) return drawable; return tintDrawable(drawable, replaceColor(context, context.getResources().getColor(colorId))); }
Example #16
Source File: KSnack.java From KSnack with Apache License 2.0 | 4 votes |
public KSnack setButtonTextColor(@NonNull @ColorRes int colorInt) { // Change button text color. btnAction.setTextColor(btnAction.getContext().getResources().getColor(colorInt)); return this; }
Example #17
Source File: ChipWidget.java From relight with Apache License 2.0 | 4 votes |
public ChipWidget closeIconTintResource(@ColorRes int id) { view.setCloseIconTintResource(id); return self(); }
Example #18
Source File: FinestWebView.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public Builder urlColorRes(@ColorRes int colorRes) { this.urlColor = ResourcesUtil.getColor(colorRes); return this; }
Example #19
Source File: FinestWebView.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public Builder progressBarColorRes(@ColorRes int colorRes) { this.progressBarColor = ResourcesUtil.getColor(colorRes); return this; }
Example #20
Source File: ContextUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static ColorStateList getColorStateList(@ColorRes int colorRes) { return ContextCompat.getColorStateList(Base.getContext(), colorRes); }
Example #21
Source File: ContextUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
@ColorInt public static int getColor(@ColorRes int colorRes) { return ContextCompat.getColor(Base.getContext(), colorRes); }
Example #22
Source File: ShadowUtils.java From 1Rramp-Android with MIT License | 4 votes |
public static Drawable generateBackgroundWithShadow(View view, @ColorRes int backgroundColor, @DimenRes int cornerRadius, @ColorRes int shadowColor, @DimenRes int elevation, int shadowGravity) { float cornerRadiusValue = view.getContext().getResources().getDimension(cornerRadius); int elevationValue = (int) view.getContext().getResources().getDimension(elevation); int shadowColorValue = ContextCompat.getColor(view.getContext(), shadowColor); int backgroundColorValue = ContextCompat.getColor(view.getContext(), backgroundColor); float[] outerRadius = {cornerRadiusValue, cornerRadiusValue, cornerRadiusValue, cornerRadiusValue, cornerRadiusValue, cornerRadiusValue, cornerRadiusValue, cornerRadiusValue}; Rect shapeDrawablePadding = new Rect(); shapeDrawablePadding.left = 0; shapeDrawablePadding.right = 0; int DY = 0; int DX = 0; switch (shadowGravity) { case Gravity.CENTER: shapeDrawablePadding.top = elevationValue; shapeDrawablePadding.bottom = elevationValue; DY = 0; break; case Gravity.RIGHT: shapeDrawablePadding.right = elevationValue * 2; shapeDrawablePadding.bottom = elevationValue * 2; DY = elevationValue / 3; DX = elevationValue / 3; break; case Gravity.TOP: shapeDrawablePadding.top = elevationValue * 2; shapeDrawablePadding.bottom = elevationValue; DY = -1 * elevationValue / 3; break; case Gravity.BOTTOM: shapeDrawablePadding.top = elevationValue; shapeDrawablePadding.bottom = elevationValue * 2; DY = elevationValue / 3; break; } ShapeDrawable shapeDrawable = new ShapeDrawable(); shapeDrawable.setPadding(shapeDrawablePadding); shapeDrawable.getPaint().setColor(backgroundColorValue); shapeDrawable.getPaint().setShadowLayer(cornerRadiusValue / 3, DX, DY, shadowColorValue); view.setLayerType(LAYER_TYPE_SOFTWARE, shapeDrawable.getPaint()); shapeDrawable.setShape(new RoundRectShape(outerRadius, null, null)); LayerDrawable drawable = new LayerDrawable(new Drawable[]{shapeDrawable}); drawable.setLayerInset(0, 0, 0, 0, elevationValue * 2); return drawable; }
Example #23
Source File: ThemeUtils.java From timecat with Apache License 2.0 | 4 votes |
public static @ColorInt int getColorById(Context context, @ColorRes int colorId) { return replaceColorById(context, colorId); }
Example #24
Source File: Colorful.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
@ColorRes public int getColorRes() { return colorRes; }
Example #25
Source File: TapTarget.java From styT with Apache License 2.0 | 4 votes |
/** * Specify the color resource for the description text **/ public TapTarget descriptionTextColor(@ColorRes int color) { this.descriptionTextColorRes = color; return this; }
Example #26
Source File: FancyWalkthroughActivity.java From FancyWalkthrough-Android with Apache License 2.0 | 4 votes |
public void setColorBackground(@ColorRes int color) { backgroundImage.setBackgroundColor(ContextCompat.getColor(this, color)); }
Example #27
Source File: TapTarget.java From styT with Apache License 2.0 | 4 votes |
/** * Specify the color resource for all text **/ public TapTarget textColor(@ColorRes int color) { this.titleTextColorRes = color; this.descriptionTextColorRes = color; return this; }
Example #28
Source File: ThemeUtils.java From timecat with Apache License 2.0 | 4 votes |
public static Drawable tintDrawable(Context context, @DrawableRes int resId, @ColorRes int colorId) { if (resId <= 0 || colorId <= 0) return null; Drawable drawable = context.getResources().getDrawable(resId); return tintDrawableByColorId(context, drawable, colorId); }
Example #29
Source File: TintTextView.java From timecat with Apache License 2.0 | 4 votes |
@Override public void setTextColorById(@ColorRes int colorId) { if (mTextHelper != null) { mTextHelper.setTextColorById(colorId); } }
Example #30
Source File: ResourcesUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static ColorStateList getColorStateList(@ColorRes int colorRes) { return ContextUtil.getColorStateList(colorRes); }