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


Java TextPaint.setColor方法代码示例

本文整理汇总了Java中android.text.TextPaint.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java TextPaint.setColor方法的具体用法?Java TextPaint.setColor怎么用?Java TextPaint.setColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.text.TextPaint的用法示例。


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

示例1: drawCenterMultiText1

import android.text.TextPaint; //导入方法依赖的package包/类
/**
 * 绘制多行居中文本(方式1)
 *
 * @param canvas 画布
 */
private void drawCenterMultiText1(Canvas canvas) {
    String text = "ABC";

    // 画笔
    TextPaint textPaint = new TextPaint();
    textPaint.setAntiAlias(true);
    textPaint.setColor(Color.GRAY);

    // 设置宽度超过50dp时换行
    StaticLayout staticLayout = new StaticLayout(text, textPaint, dp2px(50),
            Layout.Alignment.ALIGN_CENTER, 1, 0, false);
    canvas.save();
    // StaticLayout默认从(0,0)点开始绘制
    // 如果需要调整位置,只能在绘制之前移动Canvas的起始坐标
    canvas.translate(-staticLayout.getWidth() / 2, -staticLayout.getHeight() / 2);
    staticLayout.draw(canvas);
    canvas.restore();
}
 
开发者ID:alidili,项目名称:Demos,代码行数:24,代码来源:CustomTextView.java

示例2: PendingAppWidgetHostView

import android.text.TextPaint; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public PendingAppWidgetHostView(Context context, LauncherAppWidgetInfo info,
        boolean disabledForSafeMode) {
    super(new ContextThemeWrapper(context, R.style.WidgetContainerTheme));

    mLauncher = Launcher.getLauncher(context);
    mInfo = info;
    mStartState = info.restoreStatus;
    mIconLookupIntent = new Intent().setComponent(info.providerName);
    mDisabledForSafeMode = disabledForSafeMode;

    mPaint = new TextPaint();
    mPaint.setColor(0xFFFFFFFF);
    mPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,
            mLauncher.getDeviceProfile().iconTextSizePx, getResources().getDisplayMetrics()));
    setBackgroundResource(R.drawable.quantum_panel_dark);
    setWillNotDraw(false);

    if (Utilities.ATLEAST_LOLLIPOP) {
        setElevation(getResources().getDimension(R.dimen.pending_widget_elevation));
    }
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:23,代码来源:PendingAppWidgetHostView.java

示例3: AboutLinkCell

import android.text.TextPaint; //导入方法依赖的package包/类
public AboutLinkCell(Context context) {
    super(context);

    textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextSize(AndroidUtilities.dp(16));
    textPaint.setColor(0xff000000);
    textPaint.linkColor = Theme.MSG_LINK_TEXT_COLOR;
    textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));

    urlPaint = new Paint();
    urlPaint.setColor(Theme.MSG_LINK_SELECT_BACKGROUND_COLOR);
    urlPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 16, 5, LocaleController.isRTL ? 16 : 0, 0));
    setWillNotDraw(false);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:19,代码来源:AboutLinkCell.java

示例4: PieChartRenderer

import android.text.TextPaint; //导入方法依赖的package包/类
public PieChartRenderer(PieChart chart, ChartAnimator animator,
                        ViewPortHandler viewPortHandler) {
    super(animator, viewPortHandler);
    mChart = chart;

    mHolePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mHolePaint.setColor(Color.WHITE);
    mHolePaint.setStyle(Style.FILL);

    mTransparentCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTransparentCirclePaint.setColor(Color.WHITE);
    mTransparentCirclePaint.setStyle(Style.FILL);
    mTransparentCirclePaint.setAlpha(105);

    mCenterTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mCenterTextPaint.setColor(Color.BLACK);
    mCenterTextPaint.setTextSize(Utils.convertDpToPixel(12f));

    mValuePaint.setTextSize(Utils.convertDpToPixel(13f));
    mValuePaint.setColor(Color.WHITE);
    mValuePaint.setTextAlign(Align.CENTER);

    mEntryLabelsPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mEntryLabelsPaint.setColor(Color.WHITE);
    mEntryLabelsPaint.setTextAlign(Align.CENTER);
    mEntryLabelsPaint.setTextSize(Utils.convertDpToPixel(13f));

    mValueLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mValueLinePaint.setStyle(Style.STROKE);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:PieChartRenderer.java

示例5: initPaint

import android.text.TextPaint; //导入方法依赖的package包/类
private void initPaint()
{
    mTextPaint = new TextPaint();
    mTextPaint.setAntiAlias(true);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextAlign(Paint.Align.LEFT);
}
 
开发者ID:codeccc,项目名称:baselibrary-master,代码行数:9,代码来源:AutoWrapTextView.java

示例6: init

import android.text.TextPaint; //导入方法依赖的package包/类
private void init() {
    mPath = new Path();

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(bgColor);

    mTextPaint = new TextPaint();
    mTextPaint.setAntiAlias(true);
    mTextPaint.setColor(textColor);
    mTextPaint.setTextSize(textSize);
}
 
开发者ID:Othershe,项目名称:CornerLabelView,代码行数:13,代码来源:CornerLabelView.java

示例7: drawTextWithJustify

import android.text.TextPaint; //导入方法依赖的package包/类
/**
 * 重绘文字,两端对齐
 *
 * @param canvas
 */
private void drawTextWithJustify(Canvas canvas) {
    // 文字画笔
    TextPaint textPaint = getPaint();
    textPaint.setColor(getCurrentTextColor());
    textPaint.drawableState = getDrawableState();

    String text_str = getText().toString();
    // 当前所在行的Y向偏移
    int currentLineOffsetY = getPaddingTop();
    currentLineOffsetY += getTextSize();

    Layout layout = getLayout();

    //循环每一行,绘制文字
    for (int i = 0; i < layout.getLineCount(); i++) {
        int lineStart = layout.getLineStart(i);
        int lineEnd = layout.getLineEnd(i);
        //获取到TextView每行中的内容
        String line_str = text_str.substring(lineStart, lineEnd);
        // 获取每行字符串的宽度(不包括字符间距)
        float desiredWidth = StaticLayout.getDesiredWidth(text_str, lineStart, lineEnd, getPaint());

        if (isLineNeedJustify(line_str)) {
            //最后一行不需要重绘
            if (i == layout.getLineCount() - 1) {
                canvas.drawText(line_str, getPaddingLeft(), currentLineOffsetY, textPaint);
            } else {
                drawJustifyTextForLine(canvas, line_str, desiredWidth, currentLineOffsetY);
            }
        } else {
            canvas.drawText(line_str, getPaddingLeft(), currentLineOffsetY, textPaint);
        }
        //更新行Y向偏移
        currentLineOffsetY += getLineHeight();
    }
}
 
开发者ID:devilist,项目名称:AdvancedTextView,代码行数:42,代码来源:SelectableTextView.java

示例8: SecretDeleteTimer

import android.text.TextPaint; //导入方法依赖的package包/类
public SecretDeleteTimer(Context context) {
    super(context);
    setWillNotDraw(false);

    infoPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    infoPaint.setTextSize(AndroidUtilities.dp(15));
    infoPaint.setColor(0xffffffff);

    deleteProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    deleteProgressPaint.setColor(0xffe6e6e6);

    drawable = getResources().getDrawable(R.drawable.circle1);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:14,代码来源:SecretPhotoViewer.java

示例9: initPaint

import android.text.TextPaint; //导入方法依赖的package包/类
private void initPaint(){
    //绘制提示的画笔
    mTipPaint = new Paint();
    mTipPaint.setColor(mTextColor);
    mTipPaint.setTextAlign(Paint.Align.LEFT);//绘制的起始点
    mTipPaint.setTextSize(ScreenUtils.spToPx(DEFAULT_TIP_SIZE));//Tip默认的字体大小
    mTipPaint.setAntiAlias(true);
    mTipPaint.setSubpixelText(true);

    //绘制页面内容的画笔
    mTextPaint = new TextPaint();
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setAntiAlias(true);

    //绘制标题的画笔
    mTitlePaint = new TextPaint();
    mTitlePaint.setColor(mTextColor);
    mTitlePaint.setTextSize(mTitleSize);
    mTitlePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    mTitlePaint.setTypeface(Typeface.DEFAULT_BOLD);
    mTitlePaint.setAntiAlias(true);

    //绘制背景的画笔
    mBgPaint = new Paint();
    mBgPaint.setColor(mPageBg);

    mBatteryPaint = new Paint();
    mBatteryPaint.setAntiAlias(true);
    mBatteryPaint.setDither(true);
    if (isNightMode){
        mBatteryPaint.setColor(Color.WHITE);
    }
    else {
        mBatteryPaint.setColor(Color.BLACK);
    }
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:38,代码来源:PageLoader.java

示例10: updateDrawState

import android.text.TextPaint; //导入方法依赖的package包/类
@Override public void updateDrawState(final TextPaint ds) {
  if (isBold) {
    ds.setTypeface(Typeface.DEFAULT_BOLD);
  }

  ds.setUnderlineText(shouldUnderline);

  if (textColor != null) {
    ds.setColor(textColor);
  }
}
 
开发者ID:vanniktech,项目名称:TextBuilder,代码行数:12,代码来源:CustomSpan.java

示例11: init

import android.text.TextPaint; //导入方法依赖的package包/类
private void init(Context context) {
    final float density = context.getResources().getDisplayMetrics().density;

    mPaints[0] = new Paint();
    mPaints[0].setColor(0xfff5d391);

    mPaints[1] = new Paint();
    mPaints[1].setColor(0xffa9e8fe);

    mPaints[2] = new Paint();
    mPaints[2].setColor(0xffe9969c);

    mPaints[3] = new Paint();
    mPaints[3].setColor(0xffb5d951);

    mTextPaint = new TextPaint();
    mTextPaint.setColor(0xff555555);
    mTextPaint.setAntiAlias(true);
    mTextPaint.setTextSize(density * 12);

    mColumnHeight = (int)(density * 20);
    mColumnPadding = (int)(density * 2);
    mSectionPadding = (int)(density * 24);
    mDividerHeight = (int)(density * 2);
    mTextPadding = (int)(density * 4);

    for (int i = 0; i < SECTION_COUNT; i++) {
        mSections[i] = new Section();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:BarChart.java

示例12: NineGridViewWrapper

import android.text.TextPaint; //导入方法依赖的package包/类
public NineGridViewWrapper(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    //转化单位
    textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, textSize, getContext().getResources().getDisplayMetrics());

    textPaint = new TextPaint();
    textPaint.setTextAlign(Paint.Align.CENTER);  //文字居中对齐
    textPaint.setAntiAlias(true);                //抗锯齿
    textPaint.setTextSize(textSize);             //设置文字大小
    textPaint.setColor(textColor);               //设置文字颜色
}
 
开发者ID:penghuanliang,项目名称:Rxjava2.0Demo,代码行数:13,代码来源:NineGridViewWrapper.java

示例13: updateDrawState

import android.text.TextPaint; //导入方法依赖的package包/类
@Override
public void updateDrawState(TextPaint ds) {
    super.updateDrawState(ds);
    ds.setColor(ContextCompat.getColor(getContext(), R.color.light_coffee));
    ds.setUnderlineText(false);
}
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:7,代码来源:BookContentTextView.java

示例14: JuzView

import android.text.TextPaint; //导入方法依赖的package包/类
public JuzView(Context context, int type, String overlayText) {
  final Resources resources = context.getResources();
  final int circleColor = ContextCompat.getColor(context, R.color.accent_color);
  final int circleBackground = ContextCompat.getColor(context, R.color.accent_color_dark);

  mCirclePaint = new Paint();
  mCirclePaint.setStyle(Paint.Style.FILL);
  mCirclePaint.setColor(circleColor);
  mCirclePaint.setAntiAlias(true);

  mCircleBackgroundPaint = new Paint();
  mCircleBackgroundPaint.setStyle(Paint.Style.FILL);
  mCircleBackgroundPaint.setColor(circleBackground);
  mCircleBackgroundPaint.setAntiAlias(true);

  mOverlayText = overlayText;
  if (!TextUtils.isEmpty(mOverlayText)) {
    final int textColor = ContextCompat.getColor(context, R.color.header_background);
    final int textSize =
        resources.getDimensionPixelSize(R.dimen.juz_overlay_text_size);
    mOverlayTextPaint = new TextPaint();
    mOverlayTextPaint.setAntiAlias(true);
    mOverlayTextPaint.setColor(textColor);
    mOverlayTextPaint.setTextSize(textSize);
    mOverlayTextPaint.setTextAlign(Paint.Align.CENTER);

    final float textHeight =
        mOverlayTextPaint.descent() - mOverlayTextPaint.ascent();
    mTextOffset = (textHeight / 2) - mOverlayTextPaint.descent();
  }

  final int percentage;
  switch (type) {
    case TYPE_JUZ:
      percentage = 100;
      break;
    case TYPE_THREE_QUARTERS:
      percentage = 75;
      break;
    case TYPE_HALF:
      percentage = 50;
      break;
    case TYPE_QUARTER:
      percentage = 25;
      break;
    default:
      percentage = 0;
  }
  mPercentage = percentage;
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:51,代码来源:JuzView.java

示例15: updateDrawState

import android.text.TextPaint; //导入方法依赖的package包/类
@Override
public void updateDrawState(TextPaint ds) {
    ds.setColor(Utils.getContext().getResources().getColor(R.color.clickspan_color));
    ds.setUnderlineText(true);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:AnimationAdapter.java


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