本文整理汇总了Java中android.text.Layout.draw方法的典型用法代码示例。如果您正苦于以下问题:Java Layout.draw方法的具体用法?Java Layout.draw怎么用?Java Layout.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.Layout
的用法示例。
在下文中一共展示了Layout.draw方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createViewBitmap
import android.text.Layout; //导入方法依赖的package包/类
public Bitmap createViewBitmap(View view, Layout textLayout, int bitmapWidth, int bitmapHeight, int vertical_align) {
final int actualBitmapWidth = getPowerOfTwo(bitmapWidth);
final int actualBitmapHeight = getPowerOfTwo(bitmapHeight);
Bitmap destBitmap = Bitmap.createBitmap( actualBitmapWidth, actualBitmapHeight, Bitmap.Config.ARGB_8888 );
destBitmap.eraseColor(Color.TRANSPARENT);
synchronized (mCanvas) {
mCanvas.setBitmap(destBitmap);
mCanvas.save();
// Center the bitmap horizontally inside the "powerOfTwo" texture bitmap
mCanvas.translate((actualBitmapWidth - bitmapWidth) / 2, 0);
// Align vertically depending of the argument
switch (vertical_align) {
case ALIGN_BOTTOM:
mCanvas.translate(0,actualBitmapHeight - bitmapHeight);
break;
case ALIGN_TOP:
break;
case ALIGN_CENTER:
default:
mCanvas.translate(0, (actualBitmapHeight - bitmapHeight) / 2);
}
view.draw(mCanvas);
if (textLayout != null) {
// Draw the text using the TextLayout if one is provided
mCanvas.translate(0, (actualBitmapHeight - bitmapHeight) / 2);
textLayout.draw(mCanvas);
}
mCanvas.restore();
}
return destBitmap;
}
示例2: drawLayout
import android.text.Layout; //导入方法依赖的package包/类
/**
* x and y anchored to top-middle point of StaticLayout
*/
public static void drawLayout(Layout wrappedLabel, float x, float y,
Canvas canvas, TextPaint paint) {
canvas.save();
canvas.translate(x, y);
wrappedLabel.draw(canvas);
canvas.restore();
}
示例3: warmUpTextLayoutCache
import android.text.Layout; //导入方法依赖的package包/类
/**
* As warming up TextLayoutCache done in the DOM thread may manipulate UI operation,
there may be some exception, in which case the exception is ignored. After all,
this is just a warm up operation.
* @return false for warm up failure, otherwise returns true.
*/
private boolean warmUpTextLayoutCache(Layout layout) {
boolean result;
try {
layout.draw(DUMMY_CANVAS);
result = true;
} catch (Exception e) {
WXLogUtils.eTag(TAG, e);
result = false;
}
return result;
}
示例4: onDraw
import android.text.Layout; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.save();
Layout layout= getTextLayout();
if(layout!=null){
canvas.translate(getPaddingLeft(),getPaddingTop());
layout.draw(canvas);
}
canvas.restore();
}
示例5: onDraw
import android.text.Layout; //导入方法依赖的package包/类
protected void onDraw(Canvas canvas) {
int saveCount;
Layout switchText;
super.onDraw(canvas);
Rect padding = this.mTempRect;
Drawable trackDrawable = this.mTrackDrawable;
if (trackDrawable != null) {
trackDrawable.getPadding(padding);
} else {
padding.setEmpty();
}
int switchTop = this.mSwitchTop;
int switchInnerTop = switchTop + padding.top;
int switchInnerBottom = this.mSwitchBottom - padding.bottom;
Drawable thumbDrawable = this.mThumbDrawable;
if (trackDrawable != null) {
if (!this.mSplitTrack || thumbDrawable == null) {
trackDrawable.draw(canvas);
} else {
Rect insets = DrawableUtils.getOpticalBounds(thumbDrawable);
thumbDrawable.copyBounds(padding);
padding.left += insets.left;
padding.right -= insets.right;
saveCount = canvas.save();
canvas.clipRect(padding, Op.DIFFERENCE);
trackDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
saveCount = canvas.save();
if (thumbDrawable != null) {
thumbDrawable.draw(canvas);
}
if (getTargetCheckedState()) {
switchText = this.mOnLayout;
} else {
switchText = this.mOffLayout;
}
if (switchText != null) {
int cX;
int[] drawableState = getDrawableState();
if (this.mTextColors != null) {
this.mTextPaint.setColor(this.mTextColors.getColorForState(drawableState, 0));
}
this.mTextPaint.drawableState = drawableState;
if (thumbDrawable != null) {
Rect bounds = thumbDrawable.getBounds();
cX = bounds.left + bounds.right;
} else {
cX = getWidth();
}
canvas.translate((float) ((cX / 2) - (switchText.getWidth() / 2)), (float) (((switchInnerTop + switchInnerBottom) / 2) - (switchText.getHeight() / 2)));
switchText.draw(canvas);
}
canvas.restoreToCount(saveCount);
}