本文整理匯總了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();
}
示例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));
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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); //設置文字顏色
}
示例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);
}
示例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;
}
示例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);
}