當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。