Example usage for android.graphics.drawable BitmapDrawable setBounds

List of usage examples for android.graphics.drawable BitmapDrawable setBounds

Introduction

In this page you can find the example usage for android.graphics.drawable BitmapDrawable setBounds.

Prototype

public void setBounds(@NonNull Rect bounds) 

Source Link

Document

Specify a bounding rectangle for the Drawable.

Usage

From source file:com.nextgis.maplibui.fragment.ReorderedLayerView.java

/**
 * Creates the hover cell with the appropriate bitmap and of appropriate size. The hover cell's
 * BitmapDrawable is drawn on top of the bitmap every single time an invalidate call is made.
 *///from   w w w  .ja  v  a2  s  .  com
protected BitmapDrawable getAndAddHoverView(View v) {

    int w = v.getWidth();
    int h = v.getHeight();
    int top = v.getTop();
    int left = v.getLeft();

    Bitmap b = getBitmapWithBorder(v);

    BitmapDrawable drawable = new BitmapDrawable(getResources(), b);

    mHoverCellOriginalBounds = new Rect(left, top, left + w, top + h);
    mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds);

    drawable.setBounds(mHoverCellCurrentBounds);

    return drawable;
}

From source file:com.dgnt.dominionCardPicker.view.DynamicListView.java

/**
 * Creates the hover cell with the appropriate bitmap and of appropriate
 * size. The hover cell's BitmapDrawable is drawn on top of the bitmap every
 * single time an invalidate call is made.
 *//*from   w  w  w . j  a v  a  2  s. co  m*/
private BitmapDrawable getAndAddHoverView(View v) {

    int w = v.getWidth();
    int h = v.getHeight();
    int top = v.getTop();
    int left = v.getLeft();

    Bitmap b = getBitmapWithBorder(v);

    BitmapDrawable drawable = new BitmapDrawable(getResources(), b);

    mHoverCellOriginalBounds = new Rect(left, top, left + w, top + h);
    mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds);

    drawable.setBounds(mHoverCellCurrentBounds);

    return drawable;
}

From source file:com.devbrackets.android.recyclerext.decoration.ReorderDecoration.java

/**
 * Generates the Bitmap that will be used to represent the view being dragged across the screen
 *
 * @param view The view to create the drag bitmap from
 * @return The bitmap representing the drag view
 *///from   ww  w .j av  a2  s.c o m
private BitmapDrawable createDragBitmap(View view) {
    floatingItemStartingBounds = new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
    floatingItemBounds = new Rect(floatingItemStartingBounds);

    Bitmap bitmap = Bitmap.createBitmap(floatingItemStartingBounds.width(), floatingItemStartingBounds.height(),
            Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    view.draw(canvas);

    BitmapDrawable retDrawable = new BitmapDrawable(view.getResources(), bitmap);
    retDrawable.setBounds(floatingItemBounds);

    return retDrawable;
}

From source file:ucsc.hci.rankit.DynamicListView.java

/**
 * Creates the hover cell with the appropriate bitmap and of appropriate
 * size. The hover cell's BitmapDrawable is drawn on top of the bitmap every
 * single time an invalidate call is made.
 *//*from   w  w  w  . j  ava 2s  .c  o m*/
private BitmapDrawable getAndAddHoverView(View v) {

    int w = 10;
    int h = 10;
    int top = 10;
    int left = 10;
    try {
        w = v.getWidth();
        h = v.getHeight();
        top = v.getTop();
        left = v.getLeft();
    } catch (Exception e) {
        e.printStackTrace();
    }

    Bitmap b = getBitmapWithBorder(v);

    BitmapDrawable drawable = new BitmapDrawable(getResources(), b);

    mHoverCellOriginalBounds = new Rect(left, top, left + w, top + h);
    mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds);

    drawable.setBounds(mHoverCellCurrentBounds);

    return drawable;
}

From source file:net.osmand.plus.views.controls.DynamicListView.java

/**
 * Creates the hover cell with the appropriate bitmap and of appropriate
 * size. The hover cell's BitmapDrawable is drawn on top of the bitmap every
 * single time an invalidate call is made.
 *//*  ww w  .  j a va 2 s  . c  o  m*/
private BitmapDrawable getAndAddHoverView(View v) {

    int w = v.getWidth();
    int h = v.getHeight();
    int top = v.getTop();
    int left = v.getLeft();

    Bitmap b = getBitmapFromView(v);

    BitmapDrawable drawable = new BitmapDrawable(getResources(), b);

    mHoverCellOriginalBounds = new Rect(left, top, left + w, top + h);
    mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds);

    drawable.setBounds(mHoverCellCurrentBounds);

    return drawable;
}

From source file:org.androfarsh.widget.DragGridLayout.java

private boolean drawChildDrawable(BitmapDrawable childDrawable, Canvas canvas, View child, long drawingTime) {
    canvas.save();/*from  w  w  w .  jav a  2 s  .co m*/
    requestCurrentRect(mTmpRect, child);
    if (child.getAnimation() == null) {
        canvas.clipRect(mTmpRect);
    }

    final boolean result;
    if (mEditMode && (childDrawable != null) && !childDrawable.getBitmap().isRecycled()) {
        childDrawable.setBounds(mTmpRect);
        childDrawable.draw(canvas);
        result = false;
    } else {
        result = super.drawChild(canvas, child, drawingTime);
    }
    canvas.restore();
    return result;
}