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


Java NinePatchDrawable.setBounds方法代码示例

本文整理汇总了Java中android.graphics.drawable.NinePatchDrawable.setBounds方法的典型用法代码示例。如果您正苦于以下问题:Java NinePatchDrawable.setBounds方法的具体用法?Java NinePatchDrawable.setBounds怎么用?Java NinePatchDrawable.setBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.drawable.NinePatchDrawable的用法示例。


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

示例1: createDraggingItemImage

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
private Bitmap createDraggingItemImage(View v, NinePatchDrawable shadow) {
    int width = v.getWidth() + mShadowPadding.left + mShadowPadding.right;
    int height = v.getHeight() + mShadowPadding.top + mShadowPadding.bottom;

    final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    final Canvas canvas = new Canvas(bitmap);

    if (shadow != null) {
        shadow.setBounds(0, 0, width, height);
        shadow.draw(canvas);
    }

    final int savedCount = canvas.save(Canvas.CLIP_SAVE_FLAG | Canvas.MATRIX_SAVE_FLAG);
    // NOTE: Explicitly set clipping rect. This is required on Gingerbread.
    canvas.clipRect(mShadowPadding.left, mShadowPadding.top, width - mShadowPadding.right, height - mShadowPadding.bottom);
    canvas.translate(mShadowPadding.left, mShadowPadding.top);
    v.draw(canvas);
    canvas.restoreToCount(savedCount);

    return bitmap;
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:23,代码来源:DraggingItemDecorator.java

示例2: drawPopup

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
/**
 * @param canvas The canvas you need to draw on.
 * @param point  The Point consists of the x y coordinates from left bottom to right top.
 *               Like is
 *               <p/>
 *               3
 *               2
 *               1
 *               0 1 2 3 4 5
 */
private void drawPopup(Canvas canvas, String num, Point point, int PopupColor) {
    boolean singularNum = (num.length() == 1);
    int sidePadding = ChartUtils.dip2px(getContext(), singularNum ? 8 : 5);
    int x = point.x;
    int y = point.y - ChartUtils.dip2px(getContext(), 5);
    Rect popupTextRect = new Rect();
    popupTextPaint.getTextBounds(num, 0, num.length(), popupTextRect);
    Rect r = new Rect(x - popupTextRect.width() / 2 - sidePadding,
            y - popupTextRect.height() - bottomTriangleHeight - popupTopPadding * 2 - popupBottomMargin,
            x + popupTextRect.width() / 2 + sidePadding,
            y + popupTopPadding - popupBottomMargin);

    NinePatchDrawable popup = (NinePatchDrawable) getResources().getDrawable(PopupColor);
    popup.setBounds(r);
    popup.draw(canvas);
    canvas.drawText(num, x, y - bottomTriangleHeight - popupBottomMargin, popupTextPaint);
}
 
开发者ID:souliss,项目名称:soulissapp,代码行数:28,代码来源:LineView.java

示例3: drawPopup

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
/**
 *
 * @param canvas  The canvas you need to draw on.
 * @param point   The Point consists of the x y coordinates from left bottom to right top.
 *                Like is
 *
 *                3
 *                2
 *                1
 *                0 1 2 3 4 5
 */
private void drawPopup(Canvas canvas,String num, Point point,int PopupColor){
    boolean singularNum = (num.length() == 1);
    int sidePadding = MyUtils.dip2px(getContext(),singularNum? 8:5);
    int x = point.x;
    int y = point.y-MyUtils.dip2px(getContext(),5);
    Rect popupTextRect = new Rect();
    popupTextPaint.getTextBounds(num,0,num.length(),popupTextRect);
    Rect r = new Rect(x-popupTextRect.width()/2-sidePadding,
            y - popupTextRect.height()-bottomTriangleHeight-popupTopPadding*2-popupBottomMargin,
            x + popupTextRect.width()/2+sidePadding,
            y+popupTopPadding-popupBottomMargin);

    NinePatchDrawable popup = (NinePatchDrawable)getResources().getDrawable(PopupColor);
    popup.setBounds(r);
    popup.draw(canvas);
    canvas.drawText(num, x, y-bottomTriangleHeight-popupBottomMargin, popupTextPaint);
}
 
开发者ID:tomazsh,项目名称:character-lab-android-app,代码行数:29,代码来源:LineView.java

示例4: drawPopup

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
/**
 *
 * @param canvas  The canvas you need to draw on.
 * @param point   The Point consists of the x y coordinates from left bottom to right top.
 *                Like is ↓
 *                3
 *                2
 *                1
 *                0 1 2 3 4 5
 */
private void drawPopup(Canvas canvas,String num, Point point){
    boolean singularNum = (num.length() == 1);
    int sidePadding = MyUtils.dip2px(getContext(),singularNum? 8:5);
    int x = point.x;
    int y = point.y-MyUtils.dip2px(getContext(),5);
    Rect popupTextRect = new Rect();
    popupTextPaint.getTextBounds(num,0,num.length(),popupTextRect);
    Rect r = new Rect(x-popupTextRect.width()/2-sidePadding,
            y - popupTextRect.height()-bottomTriangleHeight-popupTopPadding*2-popupBottomMargin,
            x + popupTextRect.width()/2+sidePadding,
            y+popupTopPadding-popupBottomMargin);

    NinePatchDrawable popup = (NinePatchDrawable)getResources().
            getDrawable(R.drawable.popup_red);
    popup.setBounds(r);
    popup.draw(canvas);
    canvas.drawText(num, x, y-bottomTriangleHeight-popupBottomMargin, popupTextPaint);
}
 
开发者ID:dacer,项目名称:SimplePomodoro-android,代码行数:29,代码来源:LineView.java

示例5: drawPopup

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
/**
 * @param canvas The canvas you need to draw on.
 * @param point The Point consists of the x y coordinates from left bottom to right top.
 * Like is
 *
 * 3
 * 2
 * 1
 * 0 1 2 3 4 5
 */
private void drawPopup(Canvas canvas, float num, Point point, int PopupColor) {
    String numStr = showFloatNumInPopup ? String.valueOf(num) : String.valueOf(Math.round(num));
    boolean singularNum = (numStr.length() == 1);
    int sidePadding = MyUtils.dip2px(getContext(), singularNum ? 8 : 5);
    int x = point.x;
    int y = point.y - MyUtils.dip2px(getContext(), 5);
    Rect popupTextRect = new Rect();
    popupTextPaint.getTextBounds(numStr, 0, numStr.length(), popupTextRect);
    Rect r = new Rect(x - popupTextRect.width() / 2 - sidePadding, y
            - popupTextRect.height()
            - bottomTriangleHeight
            - popupTopPadding * 2
            - popupBottomMargin, x + popupTextRect.width() / 2 + sidePadding,
            y + popupTopPadding - popupBottomMargin + popupBottomPadding);

    NinePatchDrawable popup =
            (NinePatchDrawable) getResources().getDrawable(R.drawable.popup_white);
    popup.setColorFilter(new PorterDuffColorFilter(PopupColor, PorterDuff.Mode.MULTIPLY));
    popup.setBounds(r);
    popup.draw(canvas);
    canvas.drawText(numStr, x, y - bottomTriangleHeight - popupBottomMargin, popupTextPaint);
}
 
开发者ID:HackPlan,项目名称:AndroidCharts,代码行数:33,代码来源:LineView.java

示例6: addDummyBoundaryPatch

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
/**
 * Add boundary patch for external Dummy input.
 *
 * @param xTo Horizontal coordinate to which the patch should extend. The starting coordinate
 * is determined from this by subtracting patch width.
 * @param inputView The {@link InputView} for the current input. This is used to determine patch
 * height.
 * @param inputLayoutOrigin The layout origin for the current input. This is used to determine
 * the vertical position for the patch.
 */
private void addDummyBoundaryPatch(boolean isShadow, int xTo, InputView inputView,
                                   ViewPoint inputLayoutOrigin) {
    // For external dummy inputs, put a patch for the block boundary.
    final NinePatchDrawable inputDrawable = getColoredPatchDrawable(
            isShadow ? R.drawable.dummy_input_shadow : R.drawable.dummy_input);
    final NinePatchDrawable inputBorderDrawable =
            mPatchManager.getPatchDrawable(R.drawable.dummy_input_border);
    int width = inputDrawable.getIntrinsicWidth();
    if (mHasValueInput) {
        // Stretch the patch horizontally if this block has at least one value
        // input, so that the dummy input block boundary is as thick as the
        // boundary with value input connector.
        width += mPatchManager.mValueInputWidth;
    }

    boolean inTopRow = (inputLayoutOrigin.y == 0);
    mHelper.setRtlAwareBounds(tempRect,
            /* this width */  mBlockViewSize.x,
            /* LTR start */ xTo - width,
            /* top */ inputLayoutOrigin.y + (inTopRow ? mBlockTopPadding : 0),
            /* LTR end */ xTo,
            /* bottom */ inputLayoutOrigin.y + inputView.getRowHeight());
    inputDrawable.setBounds(tempRect);
    inputBorderDrawable.setBounds(tempRect);
    mBlockPatches.add(inputDrawable);
    mBlockBorderPatches.add(inputBorderDrawable);
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:38,代码来源:BlockView.java

示例7: updateShadowBounds

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
private void updateShadowBounds() {
    NinePatchDrawable shadow = mShadow;
    if (shadow == null) {
        return;
    }

    int width = getWidth();
    int height = getHeight();
    Rect paddings = mShadowPaddings;
    if (width != 0 && height != 0) {
        shadow.setBounds(-paddings.left, -paddings.top, width + paddings.right, height + paddings.bottom);
    }
}
 
开发者ID:seven332,项目名称:Nimingban,代码行数:14,代码来源:ShadowLinearLayout.java

示例8: updateNinePatchBounds

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
private void updateNinePatchBounds(NinePatchDrawable ninePatch, int childLeft, int childTop, int childRight, int childBottom) {
    if (ninePatch == null) {
        return;
    }

    final Rect t = mTempRect;
    ninePatch.getPadding(t);
    ninePatch.setBounds(
            childLeft - t.left, childTop - t.top,
            childRight + t.right, childBottom + t.bottom);
}
 
开发者ID:h6ah4i,项目名称:android-materialshadowninepatch,代码行数:12,代码来源:MaterialShadowContainerView.java

示例9: getNinepatchBitmap

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
public static Bitmap getNinepatchBitmap(int id, int x, int y, Context context) {
    Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), id);
    byte[] chunk = bitmap.getNinePatchChunk();
    NinePatchDrawable np_drawable = new NinePatchDrawable(context.getResources(), bitmap, chunk, new Rect(), null);
    np_drawable.setBounds(0, 0, x, y);
    Bitmap output_bitmap = Bitmap.createBitmap(x, y, Config.ARGB_8888);
    Canvas canvas = new Canvas(output_bitmap);
    np_drawable.draw(canvas);
    return output_bitmap;
}
 
开发者ID:muyuballs,项目名称:FxExplorer,代码行数:11,代码来源:ImageUtility.java

示例10: build

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
private void build() {
	NinePatchDrawable drawable = (NinePatchDrawable) Core.context.getResources().getDrawable(bgResId);
	drawable.setBounds(0, 0, (int)w, (int)h);

	Bitmap bgBitmap = Bitmap.createBitmap((int)w, (int)h, Bitmap.Config.ARGB_8888);
	Canvas canvas = new Canvas(bgBitmap);
	drawable.draw(canvas);
	setTextureHandle(BitmapUtils.loadBitmap(bgBitmap, textureHandle));
}
 
开发者ID:idunnololz,项目名称:DivisionByZero,代码行数:10,代码来源:BaseDialog.java

示例11: addTopLeftPatch

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
/**
 * Add the top-left corner drawable.
 *
 * @param xTo Horizontal end position for the drawable.
 * @param yTop Vertical position for the drawable.
 *
 * @return The added drawable. This can be used to position other drawables, e.g., the
 * bottom-left drawable, relative to it.
 */
@NonNull
private NinePatchDrawable addTopLeftPatch(boolean isShadow, int xTo, int yTop) {
    // Select and position the correct patch for the top and left block sides including the
    // top-left corner.
    NinePatchDrawable topStartDrawable;
    NinePatchDrawable topStartBorderDrawable;
    if (mBlock.getPreviousConnection() != null) {
        mHelper.setPointMaybeFlip(mPreviousConnectorOffset, mOutputConnectorMargin, yTop);
        topStartDrawable = getColoredPatchDrawable(isShadow
                ? R.drawable.top_start_previous_shadow : R.drawable.top_start_previous);
        topStartBorderDrawable =
                mPatchManager.getPatchDrawable(R.drawable.top_start_previous_border);
        mPreviousConnectorHighlightPatch =
                mPatchManager.getPatchDrawable(R.drawable.top_start_previous_connection);
    } else if (mBlock.getOutputConnection() != null) {
        mHelper.setPointMaybeFlip(mOutputConnectorOffset, mOutputConnectorMargin, yTop);
        topStartDrawable = getColoredPatchDrawable(
                isShadow ? R.drawable.top_start_output_shadow : R.drawable.top_start_output);
        topStartBorderDrawable =
                mPatchManager.getPatchDrawable(R.drawable.top_start_output_border);
        mOutputConnectorHighlightPatch =
                mPatchManager.getPatchDrawable(R.drawable.top_start_output_connection);
    } else if (mUseHat) {
        topStartDrawable = getColoredPatchDrawable(
                isShadow ? R.drawable.top_start_hat_shadow : R.drawable.top_start_hat);
        topStartBorderDrawable =
                mPatchManager.getPatchDrawable(R.drawable.top_start_hat_border);
    } else {
        topStartDrawable = getColoredPatchDrawable(
                isShadow ? R.drawable.top_start_default_shadow : R.drawable.top_start_default);
        topStartBorderDrawable =
                mPatchManager.getPatchDrawable(R.drawable.top_start_default_border);
    }
    mHelper.setRtlAwareBounds(tempRect,
            /* this width */ mBlockViewSize.x,
            /* LTR start */ 0,
            /* top */ 0,
            /* LTR end */ xTo,
            /* bottom */ topStartDrawable.getIntrinsicHeight());
    topStartDrawable.setBounds(tempRect);
    topStartBorderDrawable.setBounds(tempRect);
    if (mPreviousConnectorHighlightPatch != null) {
        mPreviousConnectorHighlightPatch.setBounds(tempRect);
    }
    if (mOutputConnectorHighlightPatch != null) {
        mOutputConnectorHighlightPatch.setBounds(tempRect);
    }

    mBlockPatches.add(topStartDrawable);
    mBlockBorderPatches.add(topStartBorderDrawable);
    return topStartDrawable;
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:62,代码来源:BlockView.java

示例12: addExternalValueInputPatch

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
/**
 * Add connector patch for external Value inputs.
 *
 * @param i The index of the current input. This is used to determine whether to position patch
 * vertically below the field top boundary to account for the block's top boundary.
 * @param xTo Horizontal coordinate to which the patch should extend. The starting coordinate
 * is determined from this by subtracting patch width.
 * @param inputView The {@link InputView} for the current input. This is used to determine patch
 * height.
 * @param inputLayoutOrigin The layout origin for the current input. This is used to determine
 * the vertical position for the patch.
 */
private void addExternalValueInputPatch(boolean isShadow, int i, int xTo,
                                        InputView inputView, ViewPoint inputLayoutOrigin) {
    // Position patch and connector for external value input.
    mHelper.setPointMaybeFlip(mInputConnectorOffsets.get(i), xTo, inputLayoutOrigin.y);

    final NinePatchDrawable inputDrawable = getColoredPatchDrawable(isShadow
            ? R.drawable.value_input_external_shadow : R.drawable.value_input_external);
    final NinePatchDrawable inputBorderDrawable =
            mPatchManager.getPatchDrawable(R.drawable.value_input_external_border);
    final NinePatchDrawable connectionHighlightDrawable =
            mPatchManager.getPatchDrawable(R.drawable.value_input_external_connection);

    int patchLeft = xTo - inputDrawable.getIntrinsicWidth();
    int patchRight = xTo;
    int connectorTop = inputLayoutOrigin.y + mBlockTopPadding;
    int connectorBottom = inputLayoutOrigin.y + inputView.getMeasuredHeight();

    mHelper.setRtlAwareBounds(tempRect,
            /* this width */  mBlockViewSize.x,
            /* LTR start */ patchLeft,
            /* top */ connectorTop,
            /* LTR end */ patchRight,
            /* bottom */ connectorBottom);
    inputDrawable.setBounds(tempRect);
    inputBorderDrawable.setBounds(tempRect);
    connectionHighlightDrawable.setBounds(tempRect);

    mBlockPatches.add(inputDrawable);
    mBlockBorderPatches.add(inputBorderDrawable);
    mInputConnectionHighlightPatches.set(i, connectionHighlightDrawable);

    if (i > 0) {
        // If this is not the first input in the block, then a gap above the
        // input connector patch must be closed by a non-input boundary patch.
        // The gap is the result of the need to not draw over the top block
        // boundary.
        final NinePatchDrawable boundaryGapDrawable =
                getColoredPatchDrawable(R.drawable.dummy_input);
        final NinePatchDrawable boundaryGapBorderDrawable =
                mPatchManager.getPatchDrawable(R.drawable.dummy_input_border);
        mHelper.setRtlAwareBounds(tempRect,
                /* this width */  mBlockViewSize.x,
                /* LTR start */ patchLeft,
                /* top */ inputLayoutOrigin.y,
                /* LTR end */patchRight,
                /* bottom */ connectorTop);
        boundaryGapDrawable.setBounds(tempRect);
        boundaryGapBorderDrawable.setBounds(tempRect);
        mBlockPatches.add(boundaryGapDrawable);
        mBlockBorderPatches.add(boundaryGapBorderDrawable);
    }
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:65,代码来源:BlockView.java

示例13: addStatementInputPatches

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
/**
 * Add patches (top and bottom) for a Statement input connector.
 *
 * @param i Index of the input.
 * @param xFrom Horizontal offset of block content.
 * @param xToAbove Horizontal end coordinate for connector above input.
 * @param xToBelow Horizontal end coordinate for connector below input.
 * @param inputView The view for this input.
 * @param inputLayoutOrigin Layout origin for this input.
 */
private void addStatementInputPatches(boolean isShadow, int i,
                                      int xFrom, int xToAbove, int xToBelow,
                                      InputView inputView, ViewPoint inputLayoutOrigin) {
    // Position connector. Shift by horizontal and vertical patch thickness to line up with
    // "Previous" connector on child block.
    int xOffset = xFrom + inputView.getFieldLayoutWidth();
    mHelper.setPointMaybeFlip(mInputConnectorOffsets.get(i),
            xOffset + mPatchManager.mStatementInputPadding,
            inputLayoutOrigin.y + mPatchManager.mStatementTopThickness);

    // Position patch for the top part of the Statement connector. This patch is
    // stretched only horizontally to extend to the block boundary.
    final NinePatchDrawable statementTopDrawable = getColoredPatchDrawable(
            isShadow ? R.drawable.statementinput_top_shadow : R.drawable.statementinput_top);
    final NinePatchDrawable statementTopBorderDrawable =
            mPatchManager.getPatchDrawable(R.drawable.statementinput_top_border);
    final NinePatchDrawable statementConnectionHighlight =
            mPatchManager.getPatchDrawable(R.drawable.statementinput_top_connection);

    mHelper.setRtlAwareBounds(tempRect,
            /* this width */  mBlockViewSize.x,
            /* LTR start */ xOffset,
            /* top */ inputLayoutOrigin.y,
            /* LTR end */ xToAbove,
            /* bottom */ inputLayoutOrigin.y + statementTopDrawable.getIntrinsicHeight());
    statementTopDrawable.setBounds(tempRect);
    statementTopBorderDrawable.setBounds(tempRect);
    statementConnectionHighlight.setBounds(tempRect);

    mBlockPatches.add(statementTopDrawable);
    mBlockBorderPatches.add(statementTopBorderDrawable);
    mInputConnectionHighlightPatches.set(i, statementConnectionHighlight);

    // Position patch for the bottom part of the Statement connector. The bottom
    // patch is stretched horizontally, like the top patch, but also vertically to
    // accomodate height of the input fields as well as the size of any connected
    // blocks.
    final NinePatchDrawable statementBottomDrawable = getColoredPatchDrawable(isShadow ?
            R.drawable.statementinput_bottom_shadow : R.drawable.statementinput_bottom);
    final NinePatchDrawable statementBottomBorderDrawable =
            mPatchManager.getPatchDrawable(R.drawable.statementinput_bottom_border);

    final int connectorHeight =
            Math.max(inputView.getTotalChildHeight(),
                    inputView.getMeasuredHeight());

    mHelper.setRtlAwareBounds(tempRect,
            /* this width */  mBlockViewSize.x,
            /* LTR start */ xOffset,
            /* top */ inputLayoutOrigin.y + statementTopDrawable.getIntrinsicHeight(),
            /* LTR end */ xToBelow,
            /* bottom */ inputLayoutOrigin.y + connectorHeight);
    statementBottomDrawable.setBounds(tempRect);
    statementBottomBorderDrawable.setBounds(tempRect);

    mBlockPatches.add(statementBottomDrawable);
    mBlockBorderPatches.add(statementBottomBorderDrawable);
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:69,代码来源:BlockView.java

示例14: onRender

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
/**
 * Renders a 14 line bar graph/ histogram of the FFT data
 */
@Override
public void onRender(Canvas canvas, FFTData data, Rect rect)
{
 //space between lines of graph  
 float space = 4f;

 Resources resources = mContext.getResources();
 NinePatchDrawable bg =  (NinePatchDrawable) resources.getDrawable(R.drawable.music_bar_graph);
 DisplayMetrics metrics = resources.getDisplayMetrics();
 //margin from left/right edges
 int margin = (int) ( ( 16 * (metrics.densityDpi/160f) ) + 0.5f );

 //Calculate width of each bar
 float bar_width = ( ( rect.width() - ((13 * space) + (margin * 2)) ) / 14 );
 //calculate length between the start of each bar
 float next_start = bar_width + space;
 
 for (int i = 0; i < 14; i++) {
	//set x start of bar
	float x1 = margin + (i * next_start);

	//calculate height of bar based on sampling 4 data points
	byte rfk = data.bytes[ (10 * i)];
	byte ifk = data.bytes[ (10 * i + 1)];
	float magnitude = (rfk * rfk + ifk * ifk);
	int dbValue = (int) (10 * Math.log10(magnitude));
	rfk = data.bytes[ (10 * i + 2)];
	ifk = data.bytes[ (10 * i + 3)];
	magnitude = (rfk * rfk + ifk * ifk);
	dbValue = (int) ( (10 * Math.log10(magnitude)) + dbValue) / 2;

	//Average with previous bars value(reduce spikes / smoother transitions)
	dbValue =( mData[i] +  ((dbValue < 0) ? 0 : dbValue) ) / 2;
	mData[i] = dbValue;

	//only jump height on multiples of 5
	if(dbValue >= 5)
		dbValue = (int) Math.floor(dbValue/5) * 5;

	//bottom edge of canvas
	float y1 = rect.height();
	int blockHeight = 10;
	int numBlocks = (int) Math.floor((dbValue * 8) / blockHeight);
	//cycle through and render individual blocks
	for( int j = 0; j < numBlocks; j++ ){
			int yEnd = (int)( y1 - ( blockHeight * j ));
			Rect nRect = new Rect((int)x1, yEnd - blockHeight, (int)(x1+bar_width), yEnd);
			bg.setBounds(nRect);
			bg.draw(canvas);
	}			
 }
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:56,代码来源:BarGraphRenderer.java

示例15: toRoundCorner

import android.graphics.drawable.NinePatchDrawable; //导入方法依赖的package包/类
public static Bitmap toRoundCorner(Context context, Bitmap src, Bitmap dst) {
	
	NinePatchDrawable nine = (NinePatchDrawable) context.getResources().getDrawable(R.drawable.gotye_bg_msg_text_normal_right);
	nine.setBounds(0, 0, src.getWidth(), src.getHeight());
	
	Bitmap output = Bitmap.createBitmap(src.getWidth(),
			src.getHeight(), Config.ARGB_8888);
	
	Canvas canvas = new Canvas(output);
	nine.draw(canvas);
	
	Paint paint = new Paint();
	paint.setAntiAlias(true);
	canvas.drawBitmap(dst, 0, 0, paint);
	
	paint.setXfermode(new PorterDuffXfermode(Mode.MULTIPLY));
	canvas.drawBitmap(src, 0, 0, paint);
	
	
	return output;
}
 
开发者ID:Gotye-QPlus,项目名称:GotyeSDK-Android,代码行数:22,代码来源:MainActivity.java


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