本文整理汇总了Java中android.graphics.Color.parseColor方法的典型用法代码示例。如果您正苦于以下问题:Java Color.parseColor方法的具体用法?Java Color.parseColor怎么用?Java Color.parseColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Color
的用法示例。
在下文中一共展示了Color.parseColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import android.graphics.Color; //导入方法依赖的package包/类
void open()
{
ColorDrawable[] color = {new ColorDrawable(Color.parseColor("#00ffffff")), new ColorDrawable(Color.parseColor("#CC000000"))};
TransitionDrawable trans = new TransitionDrawable(color);
//This will work also on old devices. The latest API says you have to use setBackground instead.
rel.setBackgroundDrawable(trans);
trans.startTransition(100);
//rel.setBackgroundColor(Color.parseColor("#CC000000"));
web.setVisibility(View.VISIBLE);
fb.setVisibility(View.VISIBLE);
email.setVisibility(View.VISIBLE);
webtxt.setVisibility(View.VISIBLE);
fbtxt.setVisibility(View.VISIBLE);
emailtxt.setVisibility(View.VISIBLE);
}
示例2: SpotlightConfig
import android.graphics.Color; //导入方法依赖的package包/类
public SpotlightConfig() {
this.maskColor = 0x70000000;
this.introAnimationDuration = 400;
this.isRevealAnimationEnabled = true;
this.fadingTextDuration = 400;
this.padding = 20;
this.dismissOnTouch = true;
this.dismissOnBackpress=true;
this.isPerformClick = true;
this.headingTvSize = 24;
this.headingTvSizeDimenUnit = -1;
this.headingTvColor = Color.parseColor("#eb273f");
this.headingTvText = "Hello";
this.subHeadingTvSize = 24;
this.subHeadingTvSizeDimenUnit = -1;
this.subHeadingTvColor = Color.parseColor("#ffffff");
this.subHeadingTvText = "Hello";
this.lineAnimationDuration = 300;
this.lineStroke = Utils.dpToPx(4);
this.lineAndArcColor = Color.parseColor("#eb273f");
this.showTargetArc = true;
}
示例3: foreground
import android.graphics.Color; //导入方法依赖的package包/类
/**
* ForegroundColorSpan
*/
private void foreground() {
SpannableString string = new SpannableString("设置文字的前景色为淡蓝色");
ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#0099EE"));
string.setSpan(colorSpan, 9, string.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
fgtext.setText(string);
}
示例4: linearShader
import android.graphics.Color; //导入方法依赖的package包/类
@ProtoMethod(description = "Create a linear shader", example = "")
@ProtoMethodParam(params = {"x1", "y1", "x2", "y2", "colorHex1", "colorHex2", "tileMode"})
public Shader linearShader(float x1, float y1, float x2, float y2, String c1, String c2) {
Shader.TileMode mode = Shader.TileMode.REPEAT;
Shader shader = new LinearGradient(x1, y1, x2, y2, Color.parseColor(c1), Color.parseColor(c2), mode);
return shader;
}
示例5: reset
import android.graphics.Color; //导入方法依赖的package包/类
public static void reset() {
Toasty.DEFAULT_TEXT_COLOR = Color.parseColor("#FFFFFF");
Toasty.ERROR_COLOR = Color.parseColor("#D50000");
Toasty.INFO_COLOR = Color.parseColor("#3F51B5");
Toasty.SUCCESS_COLOR = Color.parseColor("#388E3C");
Toasty.WARNING_COLOR = Color.parseColor("#FFA900");
Toasty.currentTypeface = LOADED_TOAST_TYPEFACE;
Toasty.textSize = 16;
Toasty.tintIcon = true;
}
示例6: onTouchEvent
import android.graphics.Color; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
if (ev.getX() > mStartX && ev.getX() < mIvBack.getX() - 10) {
mIsTouchColor = true;
}
break;
case MotionEvent.ACTION_MOVE:
if (mIsTouchColor && ev.getX() > mStartX && ev.getX() < mIvBack.getX() - 10) {
int i = (int) ((ev.getX() - mStartX) / mLength);
mCurrentColor = Color.parseColor(colors[i]);
mCurrentX = (int) ev.getX();
invalidate();
}
break;
case MotionEvent.ACTION_UP:
if (mIsTouchColor) {
int upX = (int) ev.getX();
if (upX < mStartX) {
upX = mStartX;
} else if (upX > mIvBack.getX() - 10) {
upX = (int) (mIvBack.getX() - 10);
}
doXAnim(mStartX + ((upX - mStartX) / mLength) * mLength + mLength / 2);
}
break;
}
return true;
}
示例7: getColorFromAttrs
import android.graphics.Color; //导入方法依赖的package包/类
public static int getColorFromAttrs(int resId, Context context, String defaultColor) {
TypedValue a = new TypedValue();
context.getTheme().resolveAttribute(resId, a, true);
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return a.data;
} else {
return Color.parseColor(defaultColor);
}
}
示例8: parseColor
import android.graphics.Color; //导入方法依赖的package包/类
public static int parseColor(String colorStr, String defaultColor) {
try {
return Color.parseColor(colorStr);
} catch (Exception e) {
return Color.parseColor(defaultColor);
}
}
示例9: setButton
import android.graphics.Color; //导入方法依赖的package包/类
static void setButton(@ColorInt int bgColor, @ColorInt int color, Button button, boolean colored) {
if (!colored) {
if (bgColor!=-1)
color = bgColor;
else
color = Color.parseColor("#ffffff");
}
int selectedColor = isColorLight(color) ?
ColorUtils.blendARGB(color, Color.parseColor("#000000"), 0.15f) :
ColorUtils.blendARGB(color, Color.parseColor("#FFFFFF"), 0.20f);
GradientDrawable drawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP,
new int[]{selectedColor, selectedColor});
GradientDrawable drawable2 = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP,
new int[]{color, color});
drawable.setCornerRadius(dpToPx(2));
drawable2.setCornerRadius(dpToPx(2));
StateListDrawable button1bg = new StateListDrawable();
button1bg.addState(new int[] {android.R.attr.state_pressed}, drawable);
button1bg.addState(new int[] {}, drawable2);
button1bg.setExitFadeDuration(250);
button.setBackgroundDrawable(button1bg);
}
示例10: createButtonBackgroundDrawable
import android.graphics.Color; //导入方法依赖的package包/类
static Drawable createButtonBackgroundDrawable(@NonNull Context context, int fillColor) {
int buttonCornerRadius = dpToPixels(context, 2);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
TypedValue v = new TypedValue();
boolean hasAttribute = context.getTheme().resolveAttribute(R.attr.colorControlHighlight, v, true);
int rippleColor = hasAttribute ? v.data : Color.parseColor("#88CCCCCC");
return createButtonBackgroundDrawableLollipop(fillColor, rippleColor, buttonCornerRadius);
}
return createButtonBackgroundDrawableBase(fillColor, buttonCornerRadius);
}
示例11: parseColor
import android.graphics.Color; //导入方法依赖的package包/类
public static int parseColor(String colorString, int defaultColor) {
try {
Integer integer = colorCache.get(colorString);
if (integer != null) {
return integer.intValue();
} else {
integer = Color.parseColor(colorString);
colorCache.put(colorString, integer);
return integer.intValue();
}
} catch (Exception e) {
return defaultColor;
}
}
示例12: randomColor
import android.graphics.Color; //导入方法依赖的package包/类
private int randomColor() {
mBuilder.delete(0, mBuilder.length()); //使用之前首先清空内容
String haxString;
for (int i = 0; i < 3; i++) {
haxString = Integer.toHexString(mRandom.nextInt(0xFF));
if (haxString.length() == 1) {
haxString = "0" + haxString;
}
mBuilder.append(haxString);
}
return Color.parseColor("#" + mBuilder.toString());
}
示例13: init
import android.graphics.Color; //导入方法依赖的package包/类
private void init(Context context) {
mPaint = new Paint();
mPaint.setAntiAlias(true);
mMaskColor = Color.parseColor("#33FFFFFF");
mCornerColor = Color.WHITE;
mCornerLength = QRCodeUtil.dp2px(context, 20);
mCornerSize = QRCodeUtil.dp2px(context, 3);
mScanLineSize = QRCodeUtil.dp2px(context, 1);
mScanLineColor = Color.WHITE;
mScanLineMargin = 0;
mIsShowDefaultScanLineDrawable = false;
mCustomScanLineDrawable = null;
mScanLineBitmap = null;
mBorderSize = QRCodeUtil.dp2px(context, 1);
mBorderColor = Color.WHITE;
mAnimTime = 1000;
mRectWidth = QRCodeUtil.dp2px(context, 200);
mMoveStepDistance = QRCodeUtil.dp2px(context, 2);
mTipText = null;
mTipTextSize = QRCodeUtil.sp2px(context, 14);
mTipTextColor = Color.WHITE;
mIsTipTextBelowRect = false;
mTipTextMargin = QRCodeUtil.dp2px(context, 20);
mIsShowTipTextAsSingleLine = false;
mTipBackgroundColor = Color.parseColor("#22000000");
mIsShowTipBackground = false;
mIsScanLineReverse = false;
mTipPaint = new TextPaint();
mTipPaint.setAntiAlias(true);
mTipBackgroundRadius = QRCodeUtil.dp2px(context, 4);
}
示例14: getSelectedColor
import android.graphics.Color; //导入方法依赖的package包/类
public
@ColorInt
int getSelectedColor() {
return selectedColor != -1 ?
selectedColor :
belongTabBar == null ?
Color.parseColor("#4169E1") :
belongTabBar.getDefaultSelectedColor();
}
示例15: getInActiveColor
import android.graphics.Color; //导入方法依赖的package包/类
/**
* @param context to fetch color
* @return in-active color (or) -1 if no color is specified
*/
protected int getInActiveColor(Context context) {
if (this.mInActiveColorResource != 0) {
return ContextCompat.getColor(context, mInActiveColorResource);
} else if (!TextUtils.isEmpty(mInActiveColorCode)) {
return Color.parseColor(mInActiveColorCode);
} else if (this.mInActiveColor != 0) {
return mInActiveColor;
} else {
return -1;
}
}