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


Java Color类代码示例

本文整理汇总了Java中android.graphics.Color的典型用法代码示例。如果您正苦于以下问题:Java Color类的具体用法?Java Color怎么用?Java Color使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testDoesNotSetErrorDrawableIfRequestCoordinatorDoesntAllowIt

import android.graphics.Color; //导入依赖的package包/类
@Test
public void testDoesNotSetErrorDrawableIfRequestCoordinatorDoesntAllowIt() {
  harness.errorDrawable = new ColorDrawable(Color.RED);
  SingleRequest<List> request = harness.getRequest();
  when(harness.requestCoordinator.canNotifyStatusChanged(any(Request.class))).thenReturn(false);
  request.onLoadFailed(new GlideException("test"));

  verify(harness.target, never()).onLoadFailed(any(Drawable.class));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:SingleRequestTest.java

示例2: getGradientColor

import android.graphics.Color; //导入依赖的package包/类
private static int getGradientColor(int startColor, int endColor, float percent)
{
    int startA = Color.alpha(startColor);
    int startR = Color.red(startColor);
    int startG = Color.green(startColor);
    int startB = Color.blue(startColor);

    int endA = Color.alpha(endColor);
    int endR = Color.red(endColor);
    int endG = Color.green(endColor);
    int endB = Color.blue(endColor);

    int currentA = (int) (startA * (1 - percent) + endA * percent);
    int currentR = (int) (startR * (1 - percent) + endR * percent);
    int currentG = (int) (startG * (1 - percent) + endG * percent);
    int currentB = (int) (startB * (1 - percent) + endB * percent);
    return Color.argb(currentA, currentR, currentG, currentB);
}
 
开发者ID:codeccc,项目名称:baselibrary-master,代码行数:19,代码来源:SmoothCheckBox.java

示例3: onCreate

import android.graphics.Color; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	super.onCreate(savedInstanceState);
	setContentView(R.layout.number_indicator_spinner);
	setCanceledOnTouchOutside(false);

	RelativeLayout content = (RelativeLayout) this.findViewById(R.id.number_indicator_spinner_content);
	indicator = new Indicator(this.getContext());
	content.addView(indicator);

	numberIndicator = new TextView(getContext());
	numberIndicator.setTextColor(Color.WHITE);
	numberIndicator.setGravity(Gravity.CENTER);
	content.addView(numberIndicator);

	indicator.setLayoutParams(new RelativeLayout.LayoutParams(
			RelativeLayout.LayoutParams.MATCH_PARENT,
			RelativeLayout.LayoutParams.MATCH_PARENT));
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:21,代码来源:Slider.java

示例4: draw

import android.graphics.Color; //导入依赖的package包/类
@Override
public void draw(Canvas canvas) {
    super.draw(canvas);

    float width = getMeasuredWidth();
    float height = getMeasuredHeight();

    for (int i = 0; i < sColors.length; i++) {
        float top = height / sColors.length * i;
        float bottom = height / sColors.length * (i + 1);
        for (int x = 0; x < sColors[i].length; x++) {
            float left = width / sColors[i].length * x;
            float right = width / sColors[i].length * (x + 1);
            mColorPaint.setColor(Color.parseColor(sColors[i][x]));
            canvas.drawRect(left, top, right, bottom, mColorPaint);
        }
    }
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:19,代码来源:ColorTable.java

示例5: onBindViewHolder

import android.graphics.Color; //导入依赖的package包/类
@Override
public void onBindViewHolder(viewHolder holder, int position) {

    HomeModel m=arrayList.get(position);
    holder.imageView.setImageResource(m.getPhoto_id());
    holder.textView.setText(m.getName());

    if(position==0)
        holder.cardView.setBackgroundColor(Color.rgb(255,205,210));
    else if(position==1)
        holder.cardView.setBackgroundColor(Color.rgb(157,255,164));
    else if(position==2)
        holder.cardView.setBackgroundColor(Color.rgb(209,196,233));
    else if(position==3)
        holder.cardView.setBackgroundColor(Color.rgb(187,222,251));
    else if(position==4)
        holder.cardView.setBackgroundColor(Color.rgb(255,204,128));
    else if(position==5)
        holder.cardView.setBackgroundColor(Color.rgb(255,245,157));
    else if(position==6)
        holder.cardView.setBackgroundColor(Color.rgb(248,187,208));
    else if(position==7)
        holder.cardView.setBackgroundColor(Color.rgb(198,193,250));

}
 
开发者ID:appteam-nith,项目名称:Hillffair17,代码行数:26,代码来源:HomeAdapter.java

示例6: onCreate

import android.graphics.Color; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	service = new Intent(this, UploadService.class);
	inputLayout = new RelativeLayout(this);
	inputLayout.setBackgroundColor(Color.WHITE);
	inputLayout.setHorizontalGravity(Gravity.CENTER_HORIZONTAL);
	inputLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	getCategory();
	initView();
	
       bindService(service, serviceConnection, Context.BIND_AUTO_CREATE);
	
       String path = getIntent().getStringExtra("filePath");
       if (path != null) {
       	filePath = path;
	}
       
       getActionBar().setDisplayHomeAsUpEnabled(true);
       uploadButton.setOnClickListener(this);
       
       setContentView(inputLayout);
}
 
开发者ID:lbbniu,项目名称:CCDownload,代码行数:24,代码来源:InputInfoActivity.java

示例7: onDraw

import android.graphics.Color; //导入依赖的package包/类
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    int width = getWidth();
    int height = getHeight();
    if (width != height) {
        int min = Math.min(width, height);
        width = min;
        height = min;
    }
    this.paint.setAntiAlias(true);
    this.paint.setColor(-1);
    canvas.drawColor(0);
    this.paint.setStrokeWidth((float) this.progressStrokeWidth);
    this.paint.setStyle(Style.STROKE);
    this.oval.left = (float) (this.progressStrokeWidth / 2);
    this.oval.top = (float) (this.progressStrokeWidth / 2);
    this.oval.right = (float) (width - (this.progressStrokeWidth / 2));
    this.oval.bottom = (float) (height - (this.progressStrokeWidth / 2));
    this.paint.setColor(Color.parseColor("#4cd964"));
    canvas.drawArc(this.oval, -90.0f, 360.0f * (((float) this.progress) / ((float) this
            .maxProgress)), false, this.paint);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:BooheeCircleProgressBar.java

示例8: SmoothLineChartView

import android.graphics.Color; //导入依赖的package包/类
public SmoothLineChartView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContext = context;
    float scale = context.getResources().getDisplayMetrics().density;
    mCircleSize = scale * CIRCLE_SIZE;
    mStrokeSize = scale * STROKE_SIZE;
    mSelectedCircleSize = scale * SELECTED_CIRCLE_SIZE;
    mEnableDrawArea = true;
    mEnableShowTag = true;
    mDrawAreaColor = (CHART_COLOR & 0xFFFFFF) | 0x10000000;
    mLineColor = CHART_COLOR;
    mCircleColor = CHART_COLOR;
    mInnerCircleColor = Color.WHITE;
    mTextColor = Color.WHITE;
    mTextSize = DensityUtils.sp2px(context, 12);
    mTextOffset = TEXT_POSITION_OFFSET;
    mNodeStyle = NODE_STYLE_CIRCLE;
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPath = new Path();
    mBorder = 2 * mCircleSize;
}
 
开发者ID:hymanme,项目名称:SmoothChartView,代码行数:23,代码来源:SmoothLineChartView.java

示例9: setup

import android.graphics.Color; //导入依赖的package包/类
public static void setup(@NonNull Activity activity, @Nullable View targetView, @ColorInt int endColor, int endCornerRadius) 
{
       final Intent intent = activity.getIntent();
       if (intent == null || !intent.hasExtra(EXTRA_SHARED_ELEMENT_START_COLOR) || !intent.hasExtra(EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS))
	{
		return;
	}

       final int startColor = activity.getIntent().getIntExtra(EXTRA_SHARED_ELEMENT_START_COLOR, Color.TRANSPARENT);
       final int startCornerRadius = intent.getIntExtra(EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS, 0);

       final MorphTransform sharedEnter = new MorphTransform(startColor, endColor, startCornerRadius, endCornerRadius);
       final MorphTransform sharedReturn = new MorphTransform(endColor, startColor, endCornerRadius, startCornerRadius);
       if (targetView != null)
	{
           sharedEnter.addTarget(targetView);
           sharedReturn.addTarget(targetView);
       }
       activity.getWindow().setSharedElementEnterTransition(sharedEnter);
       activity.getWindow().setSharedElementReturnTransition(sharedReturn);
   }
 
开发者ID:MSay2,项目名称:Mire,代码行数:22,代码来源:MorphTransform.java

示例10: onBindViewHolder

import android.graphics.Color; //导入依赖的package包/类
@Override
public void onBindViewHolder(ToastViewHolder holder, int position) {
    holder.name.setText(list.get(position).getName());
    holder.status.setText(list.get(position).getStatus());
    if(list.get(position).getStatus().toString().equals(this.context.getResources().getString(R.string.on).toString()) ){
        //holder.status.setBackgroundColor(Color.parseColor("#dff2bf"));
        holder.status.setBackgroundColor(context.getResources().getColor(R.color.colorAccent));

        holder.status.setTextColor(Color.parseColor("#4f8a10"));
    }
    else if(list.get(position).getStatus().toString().equals("off")){
        holder.status.setBackgroundColor(context.getResources().getColor(R.color.greyColor));
    }
    else {
        holder.status.setBackgroundColor(context.getResources().getColor(R.color.errorBackground));
        holder.status.setTextColor(context.getResources().getColor(R.color.errorTextColor));
    }
}
 
开发者ID:mahto56,项目名称:Qeet-Remote,代码行数:19,代码来源:ToastListAdapter.java

示例11: onClickSelectAll

import android.graphics.Color; //导入依赖的package包/类
@OnClick(R2.id.icon_shop_cart_select_all)
void onClickSelectAll() {

    final int tag = (int) mIconSelectAll.getTag();
    if (tag == 0) {
        mIconSelectAll.setTextColor
                (ContextCompat.getColor(getContext(), R.color.app_main));
        mIconSelectAll.setTag(1);
        mAdapter.setIsSelectedAll(true);
        //更新RecyclerView的显示状态
        mAdapter.notifyItemRangeChanged(0, mAdapter.getItemCount());
    } else {
        mIconSelectAll.setTextColor(Color.GRAY);
        mIconSelectAll.setTag(0);
        mAdapter.setIsSelectedAll(false);
        mAdapter.notifyItemRangeChanged(0, mAdapter.getItemCount());
    }


}
 
开发者ID:remerber,项目名称:FastEc,代码行数:21,代码来源:ShopCartDelegate.java

示例12: makeTransparent

import android.graphics.Color; //导入依赖的package包/类
public static Bitmap makeTransparent(Bitmap bit, int transparentColor) {
	int width =  bit.getWidth();
	int height = bit.getHeight();
	Bitmap myBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
	int [] allpixels = new int [ myBitmap.getHeight()*myBitmap.getWidth()];
	bit.getPixels(allpixels, 0, myBitmap.getWidth(), 0, 0, myBitmap.getWidth(), myBitmap.getHeight());
	myBitmap.setPixels(allpixels, 0, width, 0, 0, width, height);

	for(int i =0; i<myBitmap.getHeight()*myBitmap.getWidth();i++){
		if( allpixels[i] == transparentColor)
			allpixels[i] = Color.alpha(Color.TRANSPARENT);
	}

	myBitmap.setPixels(allpixels, 0, myBitmap.getWidth(), 0, 0, myBitmap.getWidth(), myBitmap.getHeight());
	return myBitmap;
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:17,代码来源:Service.java

示例13: drawArc

import android.graphics.Color; //导入依赖的package包/类
/**
 * 画扇形
 *
 * @param canvas
 */
private void drawArc(Canvas canvas) {
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.RED);
    paint.setAntiAlias(true);
    float x = (getWidth() - getHeight() / 2) / 2;
    float y = getHeight() / 4;

    RectF oval = new RectF(x, y,
            getWidth() - x, getHeight() - y);
    canvas.drawRect(oval, paint);

    Paint paint_over = new Paint();
    paint_over.setStyle(Paint.Style.FILL);
    paint_over.setColor(Color.BLUE);

    canvas.drawArc(oval, -90, 90, true, paint_over);//其中的参数 : RectF oval 一个矩形  , float startAngle 开始的偏移量 正数代表顺时针  负数代表逆时针, float sweepAngle  画圈的大下, boolean useCenter 是否连接到圆心,@NonNull Paint paint
}
 
开发者ID:songjiabin,项目名称:MySelfDemo,代码行数:24,代码来源:MyView2.java

示例14: onSurfaceTextureAvailable

import android.graphics.Color; //导入依赖的package包/类
@Override   // will be called on UI thread
public void onSurfaceTextureAvailable(SurfaceTexture st, int width, int height) {
    Log.d(TAG, "onSurfaceTextureAvailable(" + width + "x" + height + ")");
    mWidth = width;
    mHeight = height;
    mMaxAmpl = height / 2;
    mPaints.get(0).setShader(new LinearGradient(0, 0, mWidth, mHeight, Color.parseColor("#CA67B7"), Color.parseColor("#C081C1"), Shader.TileMode.MIRROR));
    mPaints.get(0).setStrokeWidth(ScreenUtils.dp2px(getContext(), 2));
    mPaints.get(1).setColor(Color.parseColor("#D5E3FA"));
    mPaints.get(1).setStrokeWidth(ScreenUtils.dp2px(getContext(), 2));
    mPaints.get(2).setStrokeWidth(ScreenUtils.dp2px(getContext(), 1));
    mPaints.get(3).setStrokeWidth(ScreenUtils.dp2px(getContext(), 1));
    mPaints.get(2).setShader(new LinearGradient(0, 0, mWidth, mHeight, Color.parseColor("#E67EA5"), Color.parseColor("#7F7AE1"), Shader.TileMode.MIRROR));
    mPaints.get(3).setShader(new LinearGradient(0, 0, mWidth, mHeight, Color.parseColor("#E67EA5"), Color.parseColor("#7F7AE1"), Shader.TileMode.MIRROR));
    synchronized (mLock) {
        mSurfaceTexture = st;
        mLock.notify();
    }
}
 
开发者ID:TheAwesomeCompany,项目名称:WaveAudioVizualization,代码行数:20,代码来源:VoiceWaveViewTV.java

示例15: PieChartRenderer

import android.graphics.Color; //导入依赖的package包/类
public PieChartRenderer(Context context, Chart chart, PieChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;
    touchAdditional = ChartUtils.dp2px(density, DEFAULT_TOUCH_ADDITIONAL_DP);

    slicePaint.setAntiAlias(true);
    slicePaint.setStyle(Paint.Style.FILL);

    centerCirclePaint.setAntiAlias(true);
    centerCirclePaint.setStyle(Paint.Style.FILL);
    centerCirclePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));

    centerCircleText1Paint.setAntiAlias(true);
    centerCircleText1Paint.setTextAlign(Align.CENTER);

    centerCircleText2Paint.setAntiAlias(true);
    centerCircleText2Paint.setTextAlign(Align.CENTER);

    separationLinesPaint.setAntiAlias(true);
    separationLinesPaint.setStyle(Paint.Style.STROKE);
    separationLinesPaint.setStrokeCap(Paint.Cap.ROUND);
    separationLinesPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    separationLinesPaint.setColor(Color.TRANSPARENT);
}
 
开发者ID:huashengzzz,项目名称:SmartChart,代码行数:25,代码来源:PieChartRenderer.java


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