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


Java DynamicLayout类代码示例

本文整理汇总了Java中android.text.DynamicLayout的典型用法代码示例。如果您正苦于以下问题:Java DynamicLayout类的具体用法?Java DynamicLayout怎么用?Java DynamicLayout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onSizeChanged

import android.text.DynamicLayout; //导入依赖的package包/类
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
	super.onSizeChanged(w, h, oldw, oldh);

	// Initialize the values;
	initializeValues();

	// Build a new Dynamic Layout with the available width since we can only provide width when the dynamic layout is created
	mDynamicLayout = new DynamicLayout(mStringBuilder, mStringBuilder, mTextPaint, w, Layout.Alignment.ALIGN_CENTER, 1.0f, 1.0f, true);
}
 
开发者ID:melvinjlobo,项目名称:Dash-Spinner,代码行数:11,代码来源:DashSpinner.java

示例2: draw

import android.text.DynamicLayout; //导入依赖的package包/类
@Override
public void draw(Canvas canvas, boolean hasPositionChanged) {
    if (shouldDrawText()) {
        float[] textPosition = getBestTextPosition();

        if (!TextUtils.isEmpty(mTitle)) {
            canvas.save();
            if (hasPositionChanged) {
                mDynamicTitleLayout = new DynamicLayout(mTitle, mPaintTitle,
                        (int) textPosition[2], Layout.Alignment.ALIGN_NORMAL,
                        1.0f, 1.0f, true);
            }
            canvas.translate(textPosition[0], textPosition[1]);
            mDynamicTitleLayout.draw(canvas);
            canvas.restore();
        }

        if (!TextUtils.isEmpty(mDetails)) {
            canvas.save();
            if (hasPositionChanged) {
                mDynamicDetailLayout = new DynamicLayout(mDetails, mPaintDetail,
                        (int) textPosition[2],
                        Layout.Alignment.ALIGN_NORMAL,
                        1.2f, 1.0f, true);
            }
            canvas.translate(textPosition[0], textPosition[1] + mDynamicTitleLayout.getHeight());
            mDynamicDetailLayout.draw(canvas);
            canvas.restore();

        }
    }
}
 
开发者ID:RayBa82,项目名称:DVBViewerController,代码行数:33,代码来源:TextDrawerImpl.java

示例3: draw

import android.text.DynamicLayout; //导入依赖的package包/类
@Override
public void draw(Canvas canvas, boolean hasPositionChanged) {
    if (shouldDrawText()) {
        float[] textPosition = getBestTextPosition();

        if (!TextUtils.isEmpty(mTitle)) {
            canvas.save();
            if (hasPositionChanged) {
                mDynamicTitleLayout = new DynamicLayout(mTitle, mPaintTitle,
                        (int) textPosition[2], Layout.Alignment.ALIGN_NORMAL,
                        1.0f, 1.0f, true);
            }
            canvas.translate(textPosition[0], textPosition[1]);
            mDynamicTitleLayout.draw(canvas);
            canvas.restore();
        }

        if (!TextUtils.isEmpty(mDetails)) {
            canvas.save();
            if (hasPositionChanged) {
                mDynamicDetailLayout = new DynamicLayout(mDetails, mPaintDetail,
                        (int) textPosition[2],
                        Layout.Alignment.ALIGN_NORMAL,
                        1.2f, 1.0f, true);
            }
            canvas.translate(textPosition[0],
                    textPosition[1] + mDynamicTitleLayout.getHeight());
            mDynamicDetailLayout.draw(canvas);
            canvas.restore();

        }
    }
}
 
开发者ID:lookwhatlook,项目名称:WeiboWeiBaTong,代码行数:34,代码来源:TextDrawerImpl.java

示例4: draw

import android.text.DynamicLayout; //导入依赖的package包/类
public void draw(Canvas canvas) {
    if (shouldDrawText()) {
        float[] textPosition = getBestTextPosition();

        if (!TextUtils.isEmpty(mTitle)) {
            canvas.save();
            if (hasRecalculated) {
                mDynamicTitleLayout = new DynamicLayout(mTitle, titlePaint,
                        (int) textPosition[2], Layout.Alignment.ALIGN_NORMAL,
                        1.0f, 1.0f, true);
            }
            if (mDynamicTitleLayout != null) {
                canvas.translate(textPosition[0], textPosition[1]);
                mDynamicTitleLayout.draw(canvas);
                canvas.restore();
            }
        }

        if (!TextUtils.isEmpty(mDetails)) {
            canvas.save();
            if (hasRecalculated) {
                mDynamicDetailLayout = new DynamicLayout(mDetails, textPaint,
                        (int) textPosition[2],
                        Layout.Alignment.ALIGN_NORMAL,
                        1.2f, 1.0f, true);
            }
            float offsetForTitle = mDynamicTitleLayout != null ? mDynamicTitleLayout.getHeight() :
                    0;
            if (mDynamicDetailLayout != null) {
                canvas.translate(textPosition[0], textPosition[1] + offsetForTitle);
                mDynamicDetailLayout.draw(canvas);
                canvas.restore();
            }

        }
    }
    hasRecalculated = false;
}
 
开发者ID:yeloapp,项目名称:yelo-android,代码行数:39,代码来源:TextDrawer.java

示例5: draw

import android.text.DynamicLayout; //导入依赖的package包/类
@Override
public void draw(Canvas canvas, boolean hasPositionChanged) {
    if (shouldDrawText()) {
        float[] textPosition = getBestTextPosition();

        if (!TextUtils.isEmpty(mTitle)) {
            canvas.save();
            if (hasPositionChanged) {
                mDynamicTitleLayout = new DynamicLayout(mTitle, mPaintTitle,
                        (int) textPosition[2], Layout.Alignment.ALIGN_NORMAL,
                        1.0f, 1.0f, true);
            }
            canvas.translate(textPosition[0], textPosition[1] - textPosition[0]);
            mDynamicTitleLayout.draw(canvas);
            canvas.restore();
        }

        if (!TextUtils.isEmpty(mDetails)) {
            canvas.save();
            if (hasPositionChanged) {
                mDynamicDetailLayout = new DynamicLayout(mDetails, mPaintDetail,
                        ((Number) textPosition[2]).intValue(),
                        Layout.Alignment.ALIGN_NORMAL,
                        1.2f, 1.0f, true);
            }
            canvas.translate(textPosition[0], textPosition[1] + 12 * mDensityScale + (
                    mDynamicTitleLayout.getLineBottom(mDynamicTitleLayout.getLineCount() - 1)
                            - mDynamicTitleLayout.getLineBottom(0)));
            mDynamicDetailLayout.draw(canvas);
            canvas.restore();

        }
    }
}
 
开发者ID:Austin-Liang,项目名称:OurDailyBread,代码行数:35,代码来源:TextDrawerImpl.java

示例6: draw

import android.text.DynamicLayout; //导入依赖的package包/类
public void draw(Canvas canvas) {
    if (shouldDrawText()) {
        float[] textPosition = getBestTextPosition();

        for (float position : textPosition) {
            if (position < 0) {
                return;
            }
        }

        if (!TextUtils.isEmpty(mTitle)) {
            canvas.save();
            if (hasRecalculated) {
                mDynamicTitleLayout = new DynamicLayout(mTitle, titlePaint,
                        (int) textPosition[2], Layout.Alignment.ALIGN_NORMAL,
                        1.0f, 1.0f, true);
            }
            if (mDynamicTitleLayout != null) {
                canvas.translate(textPosition[0], textPosition[1]);
                mDynamicTitleLayout.draw(canvas);
                canvas.restore();
            }
        }

        if (!TextUtils.isEmpty(mDetails)) {
            canvas.save();
            if (hasRecalculated) {
                mDynamicDetailLayout = new DynamicLayout(mDetails, textPaint,
                        (int) textPosition[2],
                        Layout.Alignment.ALIGN_NORMAL,
                        1.2f, 1.0f, true);
            }
            float offsetForTitle = mDynamicTitleLayout != null ? mDynamicTitleLayout.getHeight() :
                    0;
            if (mDynamicDetailLayout != null) {
                canvas.translate(textPosition[0], textPosition[1] + offsetForTitle);
                mDynamicDetailLayout.draw(canvas);
                canvas.restore();
            }

        }
    }
    hasRecalculated = false;
}
 
开发者ID:nantaphop,项目名称:AomYim-Pantip,代码行数:45,代码来源:TextDrawer.java

示例7: dispatchDraw

import android.text.DynamicLayout; //导入依赖的package包/类
@Override
protected void dispatchDraw(Canvas canvas) {
    if (showcaseX < 0 || showcaseY < 0 || isRedundant) {
        super.dispatchDraw(canvas);
        return;
    }

    Bitmap b = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(),
            Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(b);

    // Draw the semi-transparent background
    c.drawColor(backColor);

    // Draw to the scale specified
    Matrix mm = new Matrix();
    mm.postScale(scaleMultiplier, scaleMultiplier, showcaseX, showcaseY);
    c.setMatrix(mm);

    // Erase the area for the ring
    c.drawCircle(showcaseX, showcaseY, showcaseRadius, mEraser);

    boolean recalculateText = makeVoidedRect() || mAlteredText;
    mAlteredText = false;

    showcase.setBounds(voidedArea);
    showcase.draw(c);

    canvas.drawBitmap(b, 0, 0, null);

    // Clean up, as we no longer require these items.
    try {
        c.setBitmap(null);
    } catch (NullPointerException npe) {
        // TODO why does this NPE happen?
        npe.printStackTrace();
    }
    b.recycle();
    b = null;

    if (!TextUtils.isEmpty(mTitleText) || !TextUtils.isEmpty(mSubText)) {
        if (recalculateText) {
            mBestTextPosition = getBestTextPosition(canvas.getWidth(),
                    canvas.getHeight());
        }

        if (!TextUtils.isEmpty(mTitleText)) {
            // TODO: use a dynamic detail layout
            canvas.save();
            float width = mPaintTitle.measureText(mTitleText);
            canvas.rotate(mOrientation,
                    mBestTextPosition[0] + width / 2.0f,
                    mBestTextPosition[1] + mPaintTitle.getTextSize() / 2.0f);
            canvas.drawText(mTitleText, mBestTextPosition[0],
                    mBestTextPosition[1], mPaintTitle);
            canvas.restore();
        }

        if (!TextUtils.isEmpty(mSubText)) {
            canvas.save();
            if (recalculateText)
                mDynamicDetailLayout = new DynamicLayout(mSubText,
                        mPaintDetail,
                        ((Number) mBestTextPosition[2]).intValue(),
                        Layout.Alignment.ALIGN_NORMAL, 1.2f, 1.0f, true);

            if (mOrientation % 180 == 0) {
                canvas.translate(mBestTextPosition[0], mBestTextPosition[1]);
            } else {
                canvas.rotate(mOrientation,
                        mDynamicDetailLayout.getWidth() / 2,
                        mDynamicDetailLayout.getHeight() / 2);
            }

            mDynamicDetailLayout.draw(canvas);
            canvas.restore();
        }
    }

    super.dispatchDraw(canvas);
}
 
开发者ID:EatHeat,项目名称:OmniSnitch,代码行数:82,代码来源:ShowcaseView.java

示例8: createLayout

import android.text.DynamicLayout; //导入依赖的package包/类
public void createLayout(Canvas canvas, int padding) {
	Editable.Factory fac = Editable.Factory.getInstance();
	edit = fac.newEditable(stringToShow);
	dynamicLayout = new DynamicLayout(edit, textPaint, canvas.getWidth() - padding,
			Layout.Alignment.ALIGN_CENTER, 1, 0, true);
}
 
开发者ID:gorghino,项目名称:miswordfighting,代码行数:7,代码来源:Text.java

示例9: getLayout

import android.text.DynamicLayout; //导入依赖的package包/类
public DynamicLayout getLayout() {
	return this.dynamicLayout;
}
 
开发者ID:gorghino,项目名称:miswordfighting,代码行数:4,代码来源:Text.java


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