本文整理汇总了Java中android.text.TextPaint.setTextAlign方法的典型用法代码示例。如果您正苦于以下问题:Java TextPaint.setTextAlign方法的具体用法?Java TextPaint.setTextAlign怎么用?Java TextPaint.setTextAlign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.TextPaint
的用法示例。
在下文中一共展示了TextPaint.setTextAlign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.text.TextPaint; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyle) {
setWillNotDraw(false);
// Load attributes
final TypedArray a = getContext().obtainStyledAttributes(
attrs, R.styleable.FadingEdgeView, defStyle, 0);
a.recycle();
// Set up a default TextPaint object
mTextPaint = new TextPaint();
mTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setTextAlign(Paint.Align.LEFT);
// Update TextPaint and text measurements from attributes
invalidateTextPaintAndMeasurements();
}
示例2: SlidingLocaleDrawable
import android.text.TextPaint; //导入方法依赖的package包/类
@SuppressLint("ResourceAsColor")
public SlidingLocaleDrawable(Drawable background, int width, int height) {
mBackground = background;
setDefaultBounds(mBackground);
mWidth = width;
mHeight = height;
mTextPaint = new TextPaint();
mTextPaint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18));
mTextPaint.setColor(R.color.latinkeyboard_transparent);
mTextPaint.setTextAlign(Align.CENTER);
mTextPaint.setAlpha(OPACITY_FULLY_OPAQUE);
mTextPaint.setAntiAlias(true);
mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2;
mLeftDrawable =
mRes.getDrawable(R.drawable.sym_keyboard_feedback_language_arrows_left);
mRightDrawable =
mRes.getDrawable(R.drawable.sym_keyboard_feedback_language_arrows_right);
mThreshold = ViewConfiguration.get(mContext).getScaledTouchSlop();
}
示例3: init
import android.text.TextPaint; //导入方法依赖的package包/类
private void init() {
circlePaint = new Paint();
circlePaint.setAntiAlias(true);
circlePaint.setDither(true);
circlePaint.setColor(backgroundColor);
circlePaint.setStyle(Paint.Style.FILL);
textPaint = new TextPaint();
textPaint.setAntiAlias(true);
textPaint.setDither(true);
textPaint.setColor(textColor);
textPaint.setTextSize(textSize);
textPaint.setTextAlign(Paint.Align.CENTER);
borderPaint = new Paint();
borderPaint.setAntiAlias(true);
borderPaint.setDither(true);
borderPaint.setColor(borderColor);
borderPaint.setStrokeWidth(borderWidth);
borderPaint.setStyle(Paint.Style.STROKE);
int textWidth = (int) textPaint.measureText(text.substring(0, (text.length() + 1) / 2));
staticLayout = new StaticLayout(text, textPaint, textWidth, Layout.Alignment.ALIGN_NORMAL, 1F, 0, false);
}
示例4: SelectRegoinDecoration
import android.text.TextPaint; //导入方法依赖的package包/类
public SelectRegoinDecoration(Context context, DecorationCallback decorationCallback) {
Resources res = context.getResources();
this.callback = decorationCallback;
paint = new Paint();
paint.setColor(res.getColor(R.color.regoin_line));
textPaint = new TextPaint();
textPaint.setTypeface(Typeface.DEFAULT);
textPaint.setAntiAlias(true);
textPaint.setTextSize(30);
textPaint.setColor(Color.BLACK);
textPaint.getFontMetrics(fontMetrics);
textPaint.setTextAlign(Paint.Align.LEFT);
fontMetrics = new Paint.FontMetrics();
//高度
topGap = res.getDimensionPixelSize(R.dimen.sectioned_top);
}
示例5: build
import android.text.TextPaint; //导入方法依赖的package包/类
@Override
public Builder build() {
//Set the keyboard paint
mKeyPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mKeyPaint.setStyle(Paint.Style.STROKE);
mKeyPaint.setColor(mKeyStrokeColor);
mKeyPaint.setTextSize(mKeyTextSize);
mKeyPaint.setStrokeWidth(mKeyStrokeWidth);
//Set the keyboard text paint
mKeyTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
mKeyTextPaint.setColor(mKeyTextColor);
mKeyTextPaint.setTextSize(mKeyTextSize);
mKeyTextPaint.setFakeBoldText(true);
mKeyTextPaint.setTextAlign(Paint.Align.CENTER);
//Ripple paint
mClickPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mClickPaint.setStyle(Paint.Style.STROKE);
mClickPaint.setColor(Utils.makeColorDark(mKeyStrokeColor));
mClickPaint.setStrokeWidth(mKeyStrokeWidth);
return this;
}
示例6: 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); //设置文字颜色
}
示例7: initializeBackground
import android.text.TextPaint; //导入方法依赖的package包/类
/**
* Init the backgrounds and circle
*/
private void initializeBackground() {
Log.d(TAG, "Init background");
mBackgroundPaint = new Paint();
mBackgroundPaint.setColor(mCenterCircleColor);
mBackgroundPaint.setAntiAlias(true);
//Circle that holds the ticks
mCircleAndTickPaint = new Paint();
mCircleAndTickPaint.setColor(mCircleAndTickColor);
mCircleAndTickPaint.setStyle(Paint.Style.STROKE);
mCircleAndTickPaint.setStrokeWidth(THICK_STROKE);
mCircleAndTickPaint.setAntiAlias(true);
//Minute ticks
mMinuteTickPaint = new Paint();
mMinuteTickPaint.setColor(mCircleAndTickColor);
mMinuteTickPaint.setStyle(Paint.Style.STROKE);
mMinuteTickPaint.setStrokeWidth(MINUTE_TICK_STROKE);
mMinuteTickPaint.setAntiAlias(true);
mOuterBackgroundPaint = new Paint();
mOuterBackgroundPaint.setColor(mOuterCircleColor);
mOuterBackgroundPaint.setAntiAlias(true);
mHourLabelTextPaint = new TextPaint();
mHourLabelTextPaint.setColor(mHourLabelsColor);
mHourLabelTextPaint.setTextAlign(Paint.Align.CENTER);
mHourLabelTextPaint.setTypeface(mHourLabelFont);
mHourLabelTextPaint.setAntiAlias(true);
}
示例8: init
import android.text.TextPaint; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyle) {
final TypedArray a = getContext().obtainStyledAttributes(
attrs, R.styleable.ShapeLetter, defStyle, 0);
if(a.hasValue(R.styleable.ShapeLetter_letter)){
mTitleText = a.getString(R.styleable.ShapeLetter_letter);
}
mShape = a.getInteger(R.styleable.ShapeLetter_shape,DEFAULT_SHAPE);
mTitleColor = a.getColor(R.styleable.ShapeLetter_letter_color, DEFAULT_LETTER_COLOR);
mBackgroundColor = a.getColor(R.styleable.ShapeLetter_shape_color, DEFAULT_SHAPE_COLOR);
mTitleSize = a.getDimension(R.styleable.ShapeLetter_letter_size, DEFAULT_LETTER_SIZE);
a.recycle();
//Title TextPaint
mTitleTextPaint = new TextPaint();
mTitleTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
mTitleTextPaint.setTypeface(mFont);
mTitleTextPaint.setTextAlign(Paint.Align.CENTER);
mTitleTextPaint.setLinearText(true);
mTitleTextPaint.setColor(mTitleColor);
mTitleTextPaint.setTextSize(mTitleSize);
//Background Paint
mBackgroundPaint = new Paint();
mBackgroundPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
mBackgroundPaint.setStyle(Paint.Style.FILL);
mBackgroundPaint.setColor(mBackgroundColor);
mInnerRectF = new RectF();
}
示例9: init
import android.text.TextPaint; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyle) {
final TypedArray a = getContext().obtainStyledAttributes(
attrs, R.styleable.RoundedLetterView, defStyle, 0);
if(a.hasValue(R.styleable.RoundedLetterView_rlv_titleText)){
mTitleText = a.getString(R.styleable.RoundedLetterView_rlv_titleText);
}
mTitleColor = a.getColor(R.styleable.RoundedLetterView_rlv_titleColor,DEFAULT_TITLE_COLOR);
mBackgroundColor = a.getColor(R.styleable.RoundedLetterView_rlv_backgroundColorValue,DEFAULT_BACKGROUND_COLOR);
mTitleSize = a.getDimension(R.styleable.RoundedLetterView_rlv_titleSize,DEFAULT_TITLE_SIZE);
a.recycle();
//Title TextPaint
mTitleTextPaint = new TextPaint();
mTitleTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
mTitleTextPaint.setTypeface(mFont);
mTitleTextPaint.setTextAlign(Paint.Align.CENTER);
mTitleTextPaint.setLinearText(true);
mTitleTextPaint.setColor(mTitleColor);
mTitleTextPaint.setTextSize(mTitleSize);
//Background Paint
mBackgroundPaint = new Paint();
mBackgroundPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
mBackgroundPaint.setStyle(Paint.Style.FILL);
mBackgroundPaint.setColor(mBackgroundColor);
mInnerRectF = new RectF();
}
示例10: 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);
}
示例11: initPaint
import android.text.TextPaint; //导入方法依赖的package包/类
private void initPaint() {
mTextPaint = new TextPaint();
mTextPaint.setDither(true);
mTextPaint.setAntiAlias(true);
switch (mTextAlign) {
case LEFT:
mTextPaint.setTextAlign(Paint.Align.LEFT);
break;
case CENTER:
mTextPaint.setTextAlign(Paint.Align.CENTER);
break;
case RIGHT:
mTextPaint.setTextAlign(Paint.Align.RIGHT);
break;
}
mBtnPlayPaint = new Paint();
mBtnPlayPaint.setDither(true);
mBtnPlayPaint.setAntiAlias(true);
mBtnPlayPaint.setColor(mBtnColor);
mBtnPlayPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mBtnPlayPaint.setAlpha(128);
mLinePaint = new Paint();
mLinePaint.setDither(true);
mLinePaint.setAntiAlias(true);
mLinePaint.setColor(mLineColor);
mLinePaint.setAlpha(64);
mLinePaint.setStrokeWidth(1.0f);
mLinePaint.setStyle(Paint.Style.STROKE);
mTimerPaint = new Paint();
mTimerPaint.setDither(true);
mTimerPaint.setAntiAlias(true);
mTimerPaint.setColor(Color.WHITE);
mTimerPaint.setTextAlign(Paint.Align.RIGHT);
mTimerPaint.setTextSize(getRawSize(TypedValue.COMPLEX_UNIT_SP, INDICATOR_TIME_TEXT_SIZE));
}
示例12: init
import android.text.TextPaint; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.DragBadgeView);
mText = mDrawText = array.getString(R.styleable.DragBadgeView_text);
float textSize = array.getDimension(R.styleable.DragBadgeView_textSize, sp2px(10));
int bgColor = array.getColor(R.styleable.DragBadgeView_bgColor, Color.RED);
int textColor = array.getColor(R.styleable.DragBadgeView_textColor, Color.WHITE);
mMaxMoveRange = array.getDimension(R.styleable.DragBadgeView_maxMoveRange, dp2px(80));
mDragEnable = array.getBoolean(R.styleable.DragBadgeView_dragEnable, true);
mMaxShowValue = array.getInt(R.styleable.DragBadgeView_maxShowValue, 99);
array.recycle();
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setColor(bgColor);
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setAntiAlias(true);
mTextPaint.setTextAlign(Paint.Align.CENTER);
mTextPaint.setTextSize(textSize);
mTextPaint.setColor(textColor);
if (mText == null) {
mText = mDrawText = "-1";
}
measureText();
//绘制文字及背景需要的RectF
mTextRectF = new RectF();
}
示例13: TabSwitcherDrawable
import android.text.TextPaint; //导入方法依赖的package包/类
private TabSwitcherDrawable(Resources resources, boolean useLight, Bitmap bitmap) {
super(resources, bitmap);
setTint(ApiCompatibilityUtils.getColorStateList(resources,
useLight ? R.color.light_mode_tint : R.color.dark_mode_tint));
mSingleDigitTextSize =
resources.getDimension(R.dimen.toolbar_tab_count_text_size_1_digit);
mDoubleDigitTextSize =
resources.getDimension(R.dimen.toolbar_tab_count_text_size_2_digit);
mTextPaint = new TextPaint();
mTextPaint.setAntiAlias(true);
mTextPaint.setTextAlign(Align.CENTER);
mTextPaint.setTypeface(Typeface.create("sans-serif-condensed", Typeface.BOLD));
mTextPaint.setColor(getColorForState());
}
示例14: initViews
import android.text.TextPaint; //导入方法依赖的package包/类
private void initViews(Context context, AttributeSet attrs) {
tipCornerPosition = TIP_POSITION_TOP_LEFT;//默认左上角
startDisH = dp2px(context, 20);//20dp
textVPadding = dp2px(context, 2);//3dp
tipTextSize = sp2px(context, 11);//11sp
tipTextColor = Color.WHITE;//默认字体白色
tipBackgroundColor = Color.TRANSPARENT;//默认透明背景
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CornerTipView);
tipCornerPosition = typedArray.getInt(R.styleable.CornerTipView_tip_corner_position, tipCornerPosition);
realStartDisH = typedArray.getDimensionPixelSize(R.styleable.CornerTipView_tip_start_dis_x, (int) startDisH);
textVPadding = typedArray.getDimensionPixelSize(R.styleable.CornerTipView_tip_text_v_padding, textVPadding);
tipTextSize = typedArray.getDimensionPixelSize(R.styleable.CornerTipView_tip_text_size, tipTextSize);//默认12sp
tipTextColor = typedArray.getColor(R.styleable.CornerTipView_tip_text_color, tipTextColor);
tipBackgroundColor = typedArray.getColor(R.styleable.CornerTipView_tip_background, tipBackgroundColor);
tipContent = typedArray.getString(R.styleable.CornerTipView_tip_text);
typedArray.recycle();
path = new Path();
backPaint = new Paint();
backPaint.setAntiAlias(true);
backPaint.setColor(tipBackgroundColor);
textPaint = new TextPaint();
textPaint.setColor(tipTextColor);
textPaint.setTextSize(tipTextSize);
textPaint.setTextAlign(Paint.Align.CENTER);
}
示例15: preparePaint
import android.text.TextPaint; //导入方法依赖的package包/类
@Override
void preparePaint() {
mStatusTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
mStatusTextPaint.setTextAlign(Paint.Align.CENTER);
mStatusTextPaint.setTextSize(mStatusTextSize);
mStatusTextPaint.setColor(mStatusTextColor);
}