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


Java Layout.draw方法代码示例

本文整理汇总了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;
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:37,代码来源:ArtworkFactory.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:StepperIndicator.java

示例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;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:18,代码来源:WXTextDomObject.java

示例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();
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:12,代码来源:WXTextView.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:57,代码来源:SwitchCompat.java


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