當前位置: 首頁>>代碼示例>>Java>>正文


Java TextPaint.setLinearText方法代碼示例

本文整理匯總了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();
}
 
開發者ID:broakenmedia,項目名稱:MultiContactPicker,代碼行數:32,代碼來源:RoundLetterView.java

示例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();
}
 
開發者ID:karanvs,項目名稱:shapeletter,代碼行數:34,代碼來源:ShapeLetter.java

示例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);
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:53,代碼來源:CollapsingTextHelper.java


注:本文中的android.text.TextPaint.setLinearText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。