android.graphics.Color Java Examples

The following examples show how to use android.graphics.Color. 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: BorderCircleView.java    From SmartFlasher with GNU General Public License v3.0 6 votes vote down vote up
public BorderCircleView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    if (isClickable()) {
        setForeground(ViewUtils.getSelectableBackground(context));
    }
    mCheck = ContextCompat.getDrawable(context, R.drawable.ic_done);
    DrawableCompat.setTint(mCheck, Color.WHITE);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(ViewUtils.getThemeAccentColor(context));

    mPaintBorder = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintBorder.setColor(ViewUtils.getColorPrimaryColor(context));
    mPaintBorder.setStrokeWidth((int) getResources().getDimension(R.dimen.circleview_border));
    mPaintBorder.setStyle(Paint.Style.STROKE);

    setWillNotDraw(false);
}
 
Example #2
Source File: RingProgressBar.java    From YCProgress with Apache License 2.0 6 votes vote down vote up
private void initialize(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.RingProgressBar);
    // 获取自定义属性值或默认值
    progressMax = ta.getInteger(R.styleable.RingProgressBar_progressMax, 100);
    dotColor = ta.getColor(R.styleable.RingProgressBar_dotColor, Color.WHITE);
    dotBgColor = ta.getColor(R.styleable.RingProgressBar_dotBgColor, Color.GRAY);
    showMode = ta.getInt(R.styleable.RingProgressBar_showMode, ProgressBarUtils.RingShowMode.SHOW_MODE_PERCENT);

    if (showMode != ProgressBarUtils.RingShowMode.SHOW_MODE_NULL) {
        percentTextSize = ta.getDimension(R.styleable.RingProgressBar_percentTextSize, ProgressBarUtils.dp2px(context,30));
        percentTextColor = ta.getInt(R.styleable.RingProgressBar_percentTextColor, Color.WHITE);
        percentThinPadding = ta.getInt(R.styleable.RingProgressBar_percentThinPadding, 0);

        unitText = ta.getString(R.styleable.RingProgressBar_unitText);
        unitTextSize = ta.getDimension(R.styleable.RingProgressBar_unitTextSize, percentTextSize);
        unitTextColor = ta.getInt(R.styleable.RingProgressBar_unitTextColor, Color.BLACK);
        unitTextAlignMode = ta.getInt(R.styleable.RingProgressBar_unitTextAlignMode, UNIT_TEXT_ALIGN_MODE_DEFAULT);

        if (unitText == null) {
            unitText = "%";
        }
    }
    ta.recycle();
}
 
Example #3
Source File: RobotTextView.java    From NIM_Android_UIKit with MIT License 6 votes vote down vote up
@Override
public void onBindContentView() {
    if (element != null) {
        textView.setText(element.getContent());
        if (element.getColor() != null) {
            try {
                textView.setTextColor(Color.parseColor("#" + element.getColor()));
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
        } else if (color != -1) {
            textView.setTextColor(color);
        }
    } else if (!TextUtils.isEmpty(content)) {
        textView.setText(content);
    }
}
 
Example #4
Source File: OutsideLineRenderer.java    From LeafChart with Apache License 2.0 6 votes vote down vote up
/**
 * 画圆点
 * @param canvas
 */
public void drawPoints(Canvas canvas, Line line, Axis axisY, int moveX) {
    if (line != null && line.isHasPoints() && isShow) {
        List<PointValue> values = line.getValues();
        float radius = LeafUtil.dp2px(mContext, line.getPointRadius());
        float strokeWidth = LeafUtil.dp2px(mContext, 1);
        PointValue point;
        canvas.save(Canvas.CLIP_SAVE_FLAG);
        canvas.clipRect(axisY.getStartX(), 0, mWidth, mHeight);
        for (int i = 0, size = values.size(); i < size; i++) {
            point = values.get(i);
            labelPaint.setStyle(Paint.Style.FILL);
            labelPaint.setColor(line.getPointColor());
            canvas.drawCircle(point.getOriginX() + moveX, point.getOriginY(),
                    radius , labelPaint);
            labelPaint.setStyle(Paint.Style.STROKE);
            labelPaint.setColor(Color.WHITE);
            labelPaint.setStrokeWidth(strokeWidth);
            canvas.drawCircle(point.getOriginX() + moveX, point.getOriginY(),
                    radius , labelPaint);
        }
        canvas.restore();
    }
}
 
Example #5
Source File: TabSwitcherDrawable.java    From ChromeLikeTabSwitcher with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new drawable, which allows to display the number of tabs, which are currently
 * contained by a {@link TabSwitcher}.
 *
 * @param context
 *         The context, which should be used by the drawable, as an instance of the class {@link
 *         Context}. The context may not be null
 */
public TabSwitcherDrawable(@NonNull final Context context) {
    Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
    Resources resources = context.getResources();
    size = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_size);
    textSizeNormal =
            resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_normal);
    textSizeSmall =
            resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_small);
    background = ContextCompat.getDrawable(context, R.drawable.tab_switcher_drawable_background)
            .mutate();
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.WHITE);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(textSizeNormal);
    paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
    label = Integer.toString(0);
    int tint = ThemeUtil.getColor(context, android.R.attr.textColorPrimary);
    setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
}
 
Example #6
Source File: CompositorView.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link CompositorView}. This can be called only after the native library is
 * properly loaded.
 * @param c        The Context to create this {@link CompositorView} in.
 * @param host     The renderer host owning this view.
 */
public CompositorView(Context c, LayoutRenderHost host) {
    super(c);
    mRenderHost = host;

    mCompositorSurfaceManager = new CompositorSurfaceManager(this, this);

    // Cover the black surface before it has valid content.  Set this placeholder view to
    // visible, but don't yet make SurfaceView visible, in order to delay
    // surfaceCreate/surfaceChanged calls until the native library is loaded.
    setBackgroundColor(Color.WHITE);
    super.setVisibility(View.VISIBLE);

    // Request the opaque surface.  We might need the translucent one, but
    // we don't know yet.  We'll switch back later if we discover that
    // we're on a low memory device that always uses translucent.
    mCompositorSurfaceManager.requestSurface(PixelFormat.OPAQUE);
}
 
Example #7
Source File: ListFragment2.java    From visual-goodies with Apache License 2.0 6 votes vote down vote up
@Override
public void bindDataToItem(int index,
                           View itemView,
                           View detailsView,
                           ImageView imageViewOrAvatar,
                           ImageButton imageButton,
                           TextView... txt) {
    DummyObject current = (DummyObject) objects[index];

    itemView.setBackgroundColor(Color.parseColor("#F3F3F3"));

    Picasso.with(getActivity()).load((Integer) current.getAvatar()).into(imageViewOrAvatar);

    txt[0].setText(current.getName());          //1st text view's text
    txt[1].setText(current.getDescription());   //2nd

    imageButton.setImageDrawable(ContextCompat.getDrawable(getActivity(), IMAGE_BUTTON_RESID));

}
 
Example #8
Source File: PreviewBorderView.java    From TextOcrExample with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化绘图变量
 */
private void init() {
    this.mHolder = getHolder();
    this.mHolder.addCallback(this);
    this.mHolder.setFormat(PixelFormat.TRANSPARENT);
    setZOrderOnTop(true);
    setZOrderMediaOverlay(true);
    this.mPaint = new Paint();
    this.mPaint.setAntiAlias(true);
    this.mPaint.setColor(Color.WHITE);
    this.mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    this.mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    this.mPaintLine = new Paint();
    this.mPaintLine.setColor(Color.BLUE);
    this.mPaintLine.setStrokeWidth(5.0F);

    this.mTextPaint = new Paint();
    this.mTextPaint.setColor(Color.WHITE);
    this.mTextPaint.setStrokeWidth(3.0F);

    setKeepScreenOn(true);
}
 
Example #9
Source File: ImmersionBar.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 初始化android 5.0以上状态栏和导航栏
 *
 * @param uiFlags the ui flags
 * @return the int
 */
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private int initBarAboveLOLLIPOP(int uiFlags) {
    uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;  //Activity全屏显示,但状态栏不会被隐藏覆盖,状态栏依然可见,Activity顶端布局部分会被状态栏遮住。
    if (mBarParams.fullScreen && mBarParams.navigationBarEnable) {
        uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; //Activity全屏显示,但导航栏不会被隐藏覆盖,导航栏依然可见,Activity底部布局部分会被导航栏遮住。
    }
    mWindow.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    if (mConfig.hasNavigtionBar()) {  //判断是否存在导航栏
        mWindow.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }
    mWindow.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);  //需要设置这个才能设置状态栏颜色
    if (mBarParams.statusBarFlag)
        mWindow.setStatusBarColor(ColorUtils.blendARGB(mBarParams.statusBarColor,
                mBarParams.statusBarColorTransform, mBarParams.statusBarAlpha));  //设置状态栏颜色
    else
        mWindow.setStatusBarColor(ColorUtils.blendARGB(mBarParams.statusBarColor,
                Color.TRANSPARENT, mBarParams.statusBarAlpha));  //设置状态栏颜色
    if (mBarParams.navigationBarEnable)
        mWindow.setNavigationBarColor(ColorUtils.blendARGB(mBarParams.navigationBarColor,
                mBarParams.navigationBarColorTransform, mBarParams.navigationBarAlpha));  //设置导航栏颜色
    return uiFlags;
}
 
Example #10
Source File: MicrophoneVolumePicker.java    From secureit with MIT License 6 votes vote down vote up
private void drawPlot(Canvas canvas, int width) {
  float step = 10*(_drawableAreaHeight/((float)FULL_SCALE));
  float lineLevel = PADDING_TOP + _drawableAreaHeight;
  float left = PADDING_LEFT + _drawableAreaWidth/2 - 60;
  float right = PADDING_LEFT + _drawableAreaWidth/2 + 100;
  for (int i=0; i< FULL_SCALE/10 + 1; i++) {
    paint.setColor(Color.BLACK);
    if (i*10 == NOISE_THRESHOLD || i*10 == CLIPPING_THRESHOLD) {
      paint.setStrokeWidth(3.0f);
      canvas.drawLine(left, lineLevel, right, lineLevel, paint);
      paint.setStrokeWidth(0);
    } else {
      canvas.drawLine(left, lineLevel, right, lineLevel, paint);
    }
    if (i%2 == 0) {
      paint.setTextAlign(Paint.Align.RIGHT);
      canvas.drawText(Integer.toString(i*10), left - 10, lineLevel, paint);
    } else {
      paint.setTextAlign(Paint.Align.LEFT);
      canvas.drawText(Integer.toString(i*10), right + 10, lineLevel, paint);
    }
    lineLevel = lineLevel - step;
  }
}
 
Example #11
Source File: StatusBarUtil.java    From Focus with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 为 DrawerLayout 布局设置状态栏透明
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 */
public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
    } else {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
    // 内容布局不是 LinearLayout 时,设置padding top
    if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
        contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
    }

    // 设置属性
    setDrawerLayoutProperty(drawerLayout, contentLayout);
}
 
Example #12
Source File: ColorPickerView.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private ColorCircle findNearestByColor(int color) {
	float[] hsv = new float[3];
	Color.colorToHSV(color, hsv);
	ColorCircle near = null;
	double minDiff = Double.MAX_VALUE;
	double x = hsv[1] * Math.cos(hsv[0] * Math.PI / 180);
	double y = hsv[1] * Math.sin(hsv[0] * Math.PI / 180);

	for (ColorCircle colorCircle : renderer.getColorCircleList()) {
		float[] hsv1 = colorCircle.getHsv();
		double x1 = hsv1[1] * Math.cos(hsv1[0] * Math.PI / 180);
		double y1 = hsv1[1] * Math.sin(hsv1[0] * Math.PI / 180);
		double dx = x - x1;
		double dy = y - y1;
		double dist = dx * dx + dy * dy;
		if (dist < minDiff) {
			minDiff = dist;
			near = colorCircle;
		}
	}

	return near;
}
 
Example #13
Source File: SnackbarRecyclerViewSampleActivity.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
        case R.id.action_add_snackbar:
            SnackbarManager.show(
                    Snackbar.with(SnackbarRecyclerViewSampleActivity.this)
                            .text("Woo, snackbar!")
                            .actionLabel("Close")
                            .actionColor(Color.parseColor("#FF8A80"))
                            .duration(Snackbar.SnackbarDuration.LENGTH_LONG)
                            .attachToRecyclerView(mRecyclerView));
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example #14
Source File: ApiCallingFlow.java    From API-Calling-Flow with Apache License 2.0 6 votes vote down vote up
/**
 * <b>private void initializeViews()</b>
 * <p>This function is used to initialize required views.</p>
 * Created by - Rohit
 */
private void initializeViews() {
    btnTryAgain = ((Button) progressLayout.findViewById(R.id.btnTryAgain));
    btnTryAgain.setVisibility(View.GONE);
    pbLoading = ((ProgressBar) progressLayout.findViewById(R.id.progressBar));
    pbLoading.getIndeterminateDrawable().setColorFilter(ContextCompat.getColor(mContext, mProgressBarColor),
            android.graphics.PorterDuff.Mode.MULTIPLY);
    pbLoading.setVisibility(View.GONE);

    tvApiError = ((TextView) progressLayout.findViewById(R.id.tvApiError));
    tvApiError.setVisibility(View.GONE);
    ivCancel = (ImageView) progressLayout.findViewById(R.id.imgCancel);
    ivCancel.setVisibility(View.GONE);
    tvEnableNetwork = (TextView) progressLayout.findViewById(R.id.tvEnableNetwork);
    tvEnableNetwork.setVisibility(View.GONE);
    RelativeLayout rlBaseLayout = (RelativeLayout) progressLayout.findViewById(R.id.rl_base_layout);
    if (isTransparent) {
        rlBaseLayout.setBackgroundColor(Color.TRANSPARENT);
    } else {
        rlBaseLayout.setBackgroundColor(Color.WHITE);
    }
}
 
Example #15
Source File: JecActivity.java    From 920-text-editor-v2 with Apache License 2.0 6 votes vote down vote up
protected void setStatusBarColor(ViewGroup drawerLayout) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return;
    }
    if (isFullScreenMode())
        return;
    TypedArray a = getTheme().obtainStyledAttributes(new int[]{R.attr.colorPrimary});
    int color = a.getColor(0, Color.TRANSPARENT);
    a.recycle();

    if (drawerLayout != null) {
        StatusBarUtil.setColorForDrawerLayout(this, drawerLayout, color, 0);
    } else {
        StatusBarUtil.setColor(this, color, 0);
    }
}
 
Example #16
Source File: OC_Reading.java    From GLEXP-Team-onebillion with Apache License 2.0 6 votes vote down vote up
public void prepare()
{
    super.prepare();
    loadFingers();
    highlightColour = Color.RED;
    backgroundColour = Color.argb(255,0,243,243);
    sharedLock = new ReentrantLock();
    sharedCondition = sharedLock.newCondition();
    pageNo = 0;
    if (parameters.get("page") != null)
        pageNo = Integer.parseInt(parameters.get("page"));
    doArrowDemo = !OBUtils.coalesce(parameters.get("arrowdemo"),"true").equals("false");
    initialised = true;
    paragraphs = loadPageXML(getLocalPath("book.xml"));
    loadTemplate();
    int i = 1;
    for (OBReadingPara para : paragraphs)
    {
        loadTimingsPara(para,getLocalPath(String.format("p%d_%d.etpa",pageNo,i)),false);
        loadTimingsPara(para,getLocalPath(String.format("ps%d_%d.etpa",pageNo,i)),true);
        i++;
    }
    //setButtons();
    setUpScene();
}
 
Example #17
Source File: TextStreamObject.java    From rtmp-rtsp-stream-client-java with Apache License 2.0 6 votes vote down vote up
private Bitmap textAsBitmap(String text, float textSize, int textColor, Typeface typeface) {
  Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
  paint.setTextSize(textSize);
  paint.setColor(textColor);
  paint.setAlpha(255);
  if (typeface != null) paint.setTypeface(typeface);
  paint.setTextAlign(Paint.Align.LEFT);

  float baseline = -paint.ascent(); // ascent() is negative
  int width = (int) (paint.measureText(text) + 0.5f); // round
  int height = (int) (baseline + paint.descent() + 0.5f);
  Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(image);
  canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);

  canvas.drawText(text, 0, baseline, paint);
  return image;
}
 
Example #18
Source File: FloatingActionButton.java    From FloatingActionButton with Apache License 2.0 5 votes vote down vote up
private int adjustColorBrightness(int argb, float factor) {
  float[] hsv = new float[3];
  Color.colorToHSV(argb, hsv);

  hsv[2] = Math.min(hsv[2] * factor, 1f);

  return Color.HSVToColor(Color.alpha(argb), hsv);
}
 
Example #19
Source File: SunnyDayView.java    From MyWeather with Apache License 2.0 5 votes vote down vote up
@Override
protected void init() {
    super.init();
    paint = new Paint();
    paint.setStrokeWidth(3);
    paint.setAntiAlias(true);
    paint.setColor(Color.WHITE);
}
 
Example #20
Source File: NotificationHelper.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
public static Notification buildServiceNotification(String channelId, Context context, String title, String text) {
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, channelId);
    notificationBuilder
            .setSmallIcon(getNotificationIcon())
            .setOngoing(true)
            .setColor(Color.WHITE)
            .setContentTitle(title)
            .setContentText(text)
            .setProgress(100, 0, true);

    return notificationBuilder.build();
}
 
Example #21
Source File: HxImageDetailAdapter.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position)
{
    PhotoView photoView = new PhotoView(mActivity);
    photoView.setBackgroundColor(Color.BLACK);
    photoView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    photoView.setEnabled(true);
    EMImageMessageBody messageBody = (EMImageMessageBody) mDataList.get(position).getBody();
    String localUrl = messageBody.getLocalUrl();
    String remoteUrl = messageBody.getRemoteUrl();
    if (StringUtil.isNotEmpty(localUrl) && new File(localUrl).exists())
        CommonUtils.getInstance().getImageDisplayer().display(mActivity, photoView, localUrl, mScreenWidth, mScreenHeight
                , R.drawable.pic_image_detail_place_holder, R.drawable.pic_image_detail_fail);
    else
        CommonUtils.getInstance().getImageDisplayer().display(mActivity, photoView, remoteUrl, mScreenWidth, mScreenHeight
                , R.drawable.pic_image_detail_place_holder, R.drawable.pic_image_detail_fail);

    photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener()
    {
        @Override
        public void onPhotoTap(View view, float x, float y)
        {
            if (mListener != null)
                mListener.OnPhotoTapListener(view, x, y);
        }
    });
    container.addView(photoView);
    return photoView;
}
 
Example #22
Source File: StoryCardComponentSpec.java    From litho with Apache License 2.0 5 votes vote down vote up
@OnCreateLayout
static Component onCreateLayout(ComponentContext c, @Prop String content) {
  return Column.create(c)
      .backgroundColor(Color.WHITE)
      .child(
          Text.create(c, 0, R.style.message_text)
              .text(content)
              .paddingDip(HORIZONTAL, CARD_INSET)
              .paddingDip(BOTTOM, CARD_INTERNAL_PADDING))
      .child(
          Row.create(c)
              .alignSelf(STRETCH)
              .paddingDip(HORIZONTAL, CARD_INSET)
              .paddingDip(BOTTOM, CARD_INTERNAL_PADDING)
              .paddingDip(TOP, CARD_INTERNAL_PADDING)
              .justifyContent(CENTER)
              .child(
                  Image.create(c)
                      .drawableRes(R.drawable.save)
                      .alignSelf(YogaAlign.CENTER)
                      .widthDip(20)
                      .heightDip(20)
                      .marginDip(END, CARD_INTERNAL_PADDING))
              .child(Text.create(c, 0, R.style.save_text).text("Save"))
              .border(Border.create(c).color(ALL, Color.BLACK).widthDip(TOP, 1).build()))
      .border(Border.create(c).color(ALL, Color.BLACK).widthDip(ALL, 1).build())
      .build();
}
 
Example #23
Source File: ColorUtil.java    From a with GNU General Public License v3.0 5 votes vote down vote up
@ColorInt
public static int shiftColor(@ColorInt int color, @FloatRange(from = 0.0f, to = 2.0f) float by) {
    if (by == 1f) return color;
    int alpha = Color.alpha(color);
    float[] hsv = new float[3];
    Color.colorToHSV(color, hsv);
    hsv[2] *= by; // value component
    return (alpha << 24) + (0x00ffffff & Color.HSVToColor(hsv));
}
 
Example #24
Source File: FragAlarm.java    From Moring-Alarm with Apache License 2.0 5 votes vote down vote up
private void toggleAlarm(ViewHolder ho,Boolean open,AlarmInfo alarmInfo) {
    ho.Turn.setChecked(open);
    String desc="";
   if(open){
       String day=AlarmInfoDao.getDataDayofWeek(alarmInfo.getDayOfWeek());
       //判断当前的重复天数
       if(day.equals("0")){
           desc="开启      一次性闹钟";
       }else if(day.equals("1,2,3,4,5")){
           desc="开启      工作日";
       }else if(day.equals("1,2,3,4,5,6,7")){
           desc="开启      每天";
       }else if(day.equals("6,7")){
           desc="开启      周末";
       }else{
           desc="开启      每周"+day+"重复";
       }
       ho.Desc.setText(desc);
       ho.Desc.setTextColor(Color.BLACK);
       ho.Time.setTextColor(Color.BLACK);
       PrefUtils.putBoolean(mActivity, alarmInfo.getId(), true);
       //runAlarmClock(alarmInfo);
   }else{
       desc="关闭";
       ho.Desc.setText(desc);
       ho.Desc.setTextColor(Color.GRAY);
       ho.Time.setTextColor(Color.GRAY);
   }
}
 
Example #25
Source File: SlidingTabStrip.java    From PADListener with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Blend {@code color1} and {@code color2} using the given ratio.
 *
 * @param ratio of which to blend. 1.0 will return {@code color1}, 0.5 will give an even blend,
 * 0.0 will return {@code color2}.
 */
private static int blendColors(int color1, int color2, float ratio) {
	final float inverseRation = 1f - ratio;
	float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
	float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
	float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
	return Color.rgb((int) r, (int) g, (int) b);
}
 
Example #26
Source File: LineBase.java    From Virtualview-Android with MIT License 5 votes vote down vote up
public LineBase(VafContext context, ViewCache viewCache) {
    super(context, viewCache);

    mLineColor = Color.BLACK;
    mLineWidth = 1;
    mIsHorizontal = true;
    mStyle = STYLE_SOLID;
}
 
Example #27
Source File: PDFView.java    From AndroidPdfViewerV1 with Apache License 2.0 5 votes vote down vote up
/**
 * Construct the initial view
 */
public PDFView(Context context, AttributeSet set) {
    super(context, set);

    renderingHandlerThread = new HandlerThread("PDF renderer");

    if (isInEditMode()) {
        return;
    }

    miniMapRequired = false;
    cacheManager = new CacheManager();
    animationManager = new AnimationManager(this);
    dragPinchManager = new DragPinchManager(this, animationManager);

    paint = new Paint();
    debugPaint = new Paint();
    debugPaint.setStyle(Style.STROKE);
    paintMinimapBack = new Paint();
    paintMinimapBack.setStyle(Style.FILL);
    paintMinimapBack.setColor(Color.BLACK);
    paintMinimapBack.setAlpha(50);
    paintMinimapFront = new Paint();
    paintMinimapFront.setStyle(Style.FILL);
    paintMinimapFront.setColor(Color.BLACK);
    paintMinimapFront.setAlpha(50);

    // A surface view does not call
    // onDraw() as a default but we need it.
    setWillNotDraw(false);

    pdfiumCore = new PdfiumCore(context);
}
 
Example #28
Source File: CompareGLView.java    From android-openGL-canvas with Apache License 2.0 5 votes vote down vote up
private void drawCircle(ICanvasGL canvas) {
    //circle
    GLPaint circlePaint = new GLPaint();
    circlePaint.setColor(Color.parseColor("#88FF0000"));
    circlePaint.setStyle(Paint.Style.FILL);
    canvas.drawCircle(430, 30, 30, circlePaint);

    GLPaint strokeCirclePaint = new GLPaint();
    strokeCirclePaint.setColor(Color.parseColor("#88FF0000"));
    strokeCirclePaint.setLineWidth(4);
    strokeCirclePaint.setStyle(Paint.Style.STROKE);
    canvas.drawCircle(490, 30, 30, strokeCirclePaint);
}
 
Example #29
Source File: StatusbarBatteryPercentage.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private void initPreferences(XSharedPreferences prefs) {
    setTextSize(Integer.valueOf(prefs.getString(
            GravityBoxSettings.PREF_KEY_BATTERY_PERCENT_TEXT_SIZE, "16")));
    setPercentSign(prefs.getString(
            GravityBoxSettings.PREF_KEY_BATTERY_PERCENT_TEXT_STYLE, "%"));
    setChargingStyle(Integer.valueOf(prefs.getString(
            GravityBoxSettings.PREF_KEY_BATTERY_PERCENT_TEXT_CHARGING, "0")));
    setChargingColor(prefs.getInt(
            GravityBoxSettings.PREF_KEY_BATTERY_PERCENT_TEXT_CHARGING_COLOR, Color.GREEN));
}
 
Example #30
Source File: SlidingTabLayout.java    From imsdk-android with MIT License 5 votes vote down vote up
private void obtainAttributes(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingTabLayout);

    mIndicatorStyle = ta.getInt(R.styleable.SlidingTabLayout_tl_indicator_style, STYLE_NORMAL);
    mIndicatorColor = ta.getColor(R.styleable.SlidingTabLayout_tl_indicator_color, Color.parseColor(mIndicatorStyle == STYLE_BLOCK ? "#4B6A87" : "#ffffff"));
    mIndicatorHeight = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_height,
            dp2px(mIndicatorStyle == STYLE_TRIANGLE ? 4 : (mIndicatorStyle == STYLE_BLOCK ? -1 : 2)));
    mIndicatorWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_width, dp2px(mIndicatorStyle == STYLE_TRIANGLE ? 10 : -1));
    mIndicatorCornerRadius = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_corner_radius, dp2px(mIndicatorStyle == STYLE_BLOCK ? -1 : 0));
    mIndicatorMarginLeft = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_left, dp2px(0));
    mIndicatorMarginTop = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_top, dp2px(mIndicatorStyle == STYLE_BLOCK ? 7 : 0));
    mIndicatorMarginRight = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_right, dp2px(0));
    mIndicatorMarginBottom = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_bottom, dp2px(mIndicatorStyle == STYLE_BLOCK ? 7 : 0));
    mIndicatorGravity = ta.getInt(R.styleable.SlidingTabLayout_tl_indicator_gravity, Gravity.BOTTOM);
    mIndicatorWidthEqualTitle = ta.getBoolean(R.styleable.SlidingTabLayout_tl_indicator_width_equal_title, false);

    mUnderlineColor = ta.getColor(R.styleable.SlidingTabLayout_tl_underline_color, Color.parseColor("#ffffff"));
    mUnderlineHeight = ta.getDimension(R.styleable.SlidingTabLayout_tl_underline_height, dp2px(0));
    mUnderlineGravity = ta.getInt(R.styleable.SlidingTabLayout_tl_underline_gravity, Gravity.BOTTOM);

    mDividerColor = ta.getColor(R.styleable.SlidingTabLayout_tl_divider_color, Color.parseColor("#ffffff"));
    mDividerWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_divider_width, dp2px(0));
    mDividerPadding = ta.getDimension(R.styleable.SlidingTabLayout_tl_divider_padding, dp2px(12));

    mTextsize = ta.getDimension(R.styleable.SlidingTabLayout_tl_textsize, sp2px(14));
    mTextSelectColor = ta.getColor(R.styleable.SlidingTabLayout_tl_textSelectColor, Color.parseColor("#ffffff"));
    mTextUnselectColor = ta.getColor(R.styleable.SlidingTabLayout_tl_textUnselectColor, Color.parseColor("#AAffffff"));
    mTextBold = ta.getInt(R.styleable.SlidingTabLayout_tl_textBold, TEXT_BOLD_NONE);
    mTextAllCaps = ta.getBoolean(R.styleable.SlidingTabLayout_tl_textAllCaps, false);

    mTabSpaceEqual = ta.getBoolean(R.styleable.SlidingTabLayout_tl_tab_space_equal, false);
    mTabWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_tab_width, dp2px(-1));
    mTabPadding = ta.getDimension(R.styleable.SlidingTabLayout_tl_tab_padding, mTabSpaceEqual || mTabWidth > 0 ? dp2px(0) : dp2px(20));

    ta.recycle();
}