本文整理汇总了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);
}
示例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();
}
}
}
示例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();
}
}
}
示例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;
}
示例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();
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例9: getLayout
import android.text.DynamicLayout; //导入依赖的package包/类
public DynamicLayout getLayout() {
return this.dynamicLayout;
}