本文整理汇总了Java中android.text.TextPaint.setLinearText方法的典型用法代码示例。如果您正苦于以下问题:Java TextPaint.setLinearText方法的具体用法?Java TextPaint.setLinearText怎么用?Java TextPaint.setLinearText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.TextPaint
的用法示例。
在下文中一共展示了TextPaint.setLinearText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: calculateUsingTextSize
import android.text.TextPaint; //导入方法依赖的package包/类
private void calculateUsingTextSize(float textSize) {
boolean z = true;
if (this.mText != null) {
float availableWidth;
float newTextSize;
boolean updateDrawText = false;
if (isClose(textSize, this.mCollapsedTextSize)) {
availableWidth = (float) this.mCollapsedBounds.width();
newTextSize = this.mCollapsedTextSize;
this.mScale = 1.0f;
if (this.mCurrentTypeface != this.mCollapsedTypeface) {
this.mCurrentTypeface = this.mCollapsedTypeface;
updateDrawText = true;
}
} else {
availableWidth = (float) this.mExpandedBounds.width();
newTextSize = this.mExpandedTextSize;
if (this.mCurrentTypeface != this.mExpandedTypeface) {
this.mCurrentTypeface = this.mExpandedTypeface;
updateDrawText = true;
}
if (isClose(textSize, this.mExpandedTextSize)) {
this.mScale = 1.0f;
} else {
this.mScale = textSize / this.mExpandedTextSize;
}
}
if (availableWidth > 0.0f) {
if (this.mCurrentTextSize != newTextSize || this.mBoundsChanged || updateDrawText) {
updateDrawText = true;
} else {
updateDrawText = false;
}
this.mCurrentTextSize = newTextSize;
this.mBoundsChanged = false;
}
if (this.mTextToDraw == null || updateDrawText) {
this.mTextPaint.setTextSize(this.mCurrentTextSize);
this.mTextPaint.setTypeface(this.mCurrentTypeface);
TextPaint textPaint = this.mTextPaint;
if (this.mScale == 1.0f) {
z = false;
}
textPaint.setLinearText(z);
CharSequence title = TextUtils.ellipsize(this.mText, this.mTextPaint, availableWidth, TruncateAt.END);
if (!TextUtils.equals(title, this.mTextToDraw)) {
this.mTextToDraw = title;
this.mIsRtl = calculateIsRtl(this.mTextToDraw);
}
}
}
}