當前位置: 首頁>>代碼示例>>Java>>正文


Java BitmapDrawable.setBounds方法代碼示例

本文整理匯總了Java中android.graphics.drawable.BitmapDrawable.setBounds方法的典型用法代碼示例。如果您正苦於以下問題:Java BitmapDrawable.setBounds方法的具體用法?Java BitmapDrawable.setBounds怎麽用?Java BitmapDrawable.setBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.BitmapDrawable的用法示例。


在下文中一共展示了BitmapDrawable.setBounds方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: load

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private void load(Context context, @DrawableRes int drawableRes, int textSize, String url) {
    if (!nativeLoad(handle, url)) {
        nativeClose(handle);
        throw new RuntimeException("not gif");
    } else {
        frameNum = nativeGetFrameCount(handle);
        for (int i = 0; i < frameNum; i++) {
            BitmapDrawable drawable = new BitmapDrawable(context.getResources(), nativeGetFrame(handle, i));
            int width = (textSize * drawable.getIntrinsicWidth()) / drawable.getIntrinsicHeight();
            drawable.setBounds(0, 0, width, textSize);
            EmoticonCache.saveDrawable(drawableRes, i, drawable);
            delay = nativeGetDelay(handle, i);
        }
        nativeClose(handle);
    }
}
 
開發者ID:hoanganhtuan95ptit,項目名稱:GifEmoticon,代碼行數:17,代碼來源:EmoticonDecoder.java

示例2: createAndPutChipForUser

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private ChipSpan createAndPutChipForUser(TLRPC.User user) {
    LayoutInflater lf = (LayoutInflater) ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    View textView = lf.inflate(R.layout.group_create_bubble, null);
    TextView text = (TextView)textView.findViewById(R.id.bubble_text_view);
    String name = UserObject.getUserName(user);
    if (name.length() == 0 && user.phone != null && user.phone.length() != 0) {
        name = PhoneFormat.getInstance().format("+" + user.phone);
    }
    text.setText(name + ", ");

    int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    textView.measure(spec, spec);
    textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
    Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(b);
    canvas.translate(-textView.getScrollX(), -textView.getScrollY());
    textView.draw(canvas);
    textView.setDrawingCacheEnabled(true);
    Bitmap cacheBmp = textView.getDrawingCache();
    Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true);
    textView.destroyDrawingCache();

    final BitmapDrawable bmpDrawable = new BitmapDrawable(b);
    bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight());

    SpannableStringBuilder ssb = new SpannableStringBuilder("");
    ChipSpan span = new ChipSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE);
    allSpans.add(span);
    selectedContacts.put(user.id, span);
    for (ImageSpan sp : allSpans) {
        ssb.append("<<");
        ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    userSelectEditText.setText(ssb);
    userSelectEditText.setSelection(ssb.length());
    return span;
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:38,代碼來源:GroupCreateActivity.java

示例3: createFloatingBitmap

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private BitmapDrawable createFloatingBitmap(View v) {
    floatingItemStatingBounds = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
    floatingItemBounds = new Rect(floatingItemStatingBounds);

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

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

    return retDrawable;
}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:15,代碼來源:DragSortRecycler.java

示例4: fetchCompressedDrawable

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
/**
 * Get the compressed image with specific quality from URL
 */
public Drawable fetchCompressedDrawable(Resources res, String urlString) {
    try {
        InputStream is = fetch(urlString);
        Bitmap original = new BitmapDrawable(res, is).getBitmap();

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Bitmap.CompressFormat compressFormat = (urlString.endsWith(".png") || urlString.endsWith(".PNG"))
                ? Bitmap.CompressFormat.PNG
                : Bitmap.CompressFormat.JPEG;
        original.compress(compressFormat, qualityImage, out);
        original.recycle();
        is.close();

        Bitmap decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray()));
        out.close();

        scale = getScale(decoded.getWidth());
        BitmapDrawable b = new BitmapDrawable(res, decoded);

        b.setBounds(0, 0, (int) (b.getIntrinsicWidth() * scale), (int) (b.getIntrinsicHeight() * scale));
        return b;
    } catch (Exception e) {
        return null;
    }
}
 
開發者ID:mzlogin,項目名稱:guanggoo-android,代碼行數:29,代碼來源:MyHtmlHttpImageGetter.java

示例5: AnimatedGifDrawable

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
public AnimatedGifDrawable(InputStream source, UpdateListener listener) {
	mListener = listener;
	GifDecoder decoder = new GifDecoder();
	decoder.read(source);
	// Iterate through the gif frames, add each as animation frame
	for (int i = 0; i < decoder.getFrameCount(); i++) {
		Bitmap bitmap = decoder.getFrame(i);
		BitmapDrawable drawable = new BitmapDrawable(bitmap);
		// Explicitly set the bounds in order for the frames to display
		drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
		addFrame(drawable, decoder.getDelay(i));
		if (i == 0) {
			// Also set the bounds for this container drawable
			setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
		}
	}
}
 
開發者ID:DyncKathline,項目名稱:LiveGiftLayout,代碼行數:18,代碼來源:AnimatedGifDrawable.java

示例6: fetchCompressedDrawable

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
/**
 * Get the compressed image with specific quality from URL
 */
public Drawable fetchCompressedDrawable(Resources res, String urlString) {
    try {
        InputStream is = fetch(urlString);
        Bitmap original = new BitmapDrawable(res, is).getBitmap();

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        original.compress(Bitmap.CompressFormat.JPEG, qualityImage, out);
        original.recycle();
        is.close();

        Bitmap decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray()));
        out.close();

        scale = getScale(decoded);
        BitmapDrawable b = new BitmapDrawable(res, decoded);

        b.setBounds(0, 0, (int) (b.getIntrinsicWidth() * scale), (int) (b.getIntrinsicHeight() * scale));
        return b;
    } catch (Exception e) {
        return null;
    }
}
 
開發者ID:RanKKI,項目名稱:PSNine,代碼行數:26,代碼來源:HtmlHttpImageGetter.java

示例7: centerCrop

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
/**
 * 居中剪切圖片
 */
public static Bitmap centerCrop(Resources res, Bitmap bitmap, int width, int height) {
    if (bitmap == null) {
        return null;
    }
    Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    Matrix matrix = new Matrix();

    float scale;
    float dx = 0, dy = 0;

    final int dwidth = bitmap.getWidth();
    final int dheight = bitmap.getHeight();

    final int vwidth = width;
    final int vheight = height;

    if (dwidth * vheight > vwidth * dheight) {
        scale = (float) vheight / (float) dheight;
        dx = (vwidth - dwidth * scale) * 0.5f;
    } else {
        scale = (float) vwidth / (float) dwidth;
        dy = (vheight - dheight * scale) * 0.5f;
    }

    matrix.setScale(scale, scale);
    matrix.postTranslate(Math.round(dx), Math.round(dy));

    Canvas canvas = new Canvas(result);
    canvas.concat(matrix);
    BitmapDrawable bitmapDrawable = new BitmapDrawable(res, bitmap);
    bitmapDrawable.setBounds(0, 0, dwidth, dheight);
    bitmapDrawable.draw(canvas);

    return result;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:40,代碼來源:ImagePickerImageView.java

示例8: getDrawable

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
public Drawable getDrawable(Resources resources) {
    if (gifDrawable == null) {
        BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, bitmap);
        bitmapDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
        return bitmapDrawable;
    } else {
        return gifDrawable;
    }
}
 
開發者ID:nichbar,項目名稱:Aequorea,代碼行數:10,代碼來源:ImageWrapper.java

示例9: loadFromMemory

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
@NonNull
private Drawable loadFromMemory(ImageHolder holder, TextView textView, DrawableWrapper drawableWrapper) {
    BitmapWrapper bitmapWrapper = BitmapPool.getPool().get(holder.getKey(), false, true);
    Bitmap bitmap = bitmapWrapper.getBitmap();
    BitmapDrawable bitmapDrawable = new BitmapDrawable(textView.getResources(), bitmap);
    bitmapDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
    drawableWrapper.setDrawable(bitmapDrawable);
    BitmapWrapper.SizeCacheHolder sizeCacheHolder = bitmapWrapper.getSizeCacheHolder();
    drawableWrapper.setBounds(sizeCacheHolder.rect);
    drawableWrapper.setScaleType(sizeCacheHolder.scaleType);
    drawableWrapper.calculate();
    return drawableWrapper;
}
 
開發者ID:nichbar,項目名稱:Aequorea,代碼行數:14,代碼來源:DefaultImageGetter.java

示例10: getAndAddHoverView

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private BitmapDrawable getAndAddHoverView(View v, float scale){
    int w = v.getWidth();
    int h = v.getHeight();
    int top = v.getTop();
    int left = v.getLeft();

    Bitmap b = getBitmapWithBorder(v,scale);
    BitmapDrawable drawable = new BitmapDrawable(getResources(),b);
    mHoverCellOriginalBounds = new Rect(left,top,left+w,top+h);
    mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds);
    drawable.setBounds(mHoverCellCurrentBounds);
    return drawable;
}
 
開發者ID:tangqipeng,項目名稱:draggable-tree-itemview,代碼行數:14,代碼來源:DraggableTreeView.java

示例11: createAndPutChipForUser

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private ChipSpan createAndPutChipForUser(TLRPC.User user) {
    try {
        LayoutInflater lf = (LayoutInflater) ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        View textView = lf.inflate(R.layout.group_create_bubble, null);
        TextView text = (TextView)textView.findViewById(R.id.bubble_text_view);
        String name = UserObject.getUserName(user);
        if (name.length() == 0 && user.phone != null && user.phone.length() != 0) {
            name = PhoneFormat.getInstance().format("+" + user.phone);
        }
        text.setText(name + ", ");

        int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        textView.measure(spec, spec);
        textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
        Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(b);
        canvas.translate(-textView.getScrollX(), -textView.getScrollY());
        textView.draw(canvas);
        textView.setDrawingCacheEnabled(true);
        Bitmap cacheBmp = textView.getDrawingCache();
        Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true);
        textView.destroyDrawingCache();

        final BitmapDrawable bmpDrawable = new BitmapDrawable(b);
        bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight());

        SpannableStringBuilder ssb = new SpannableStringBuilder("");
        ChipSpan span = new ChipSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE);
        allSpans.add(span);
        selectedContacts.put(user.id, span);
        for (ImageSpan sp : allSpans) {
            ssb.append("<<");
            ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        nameTextView.setText(ssb);
        nameTextView.setSelection(ssb.length());
        return span;
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
    return null;
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:43,代碼來源:ChannelCreateActivity.java

示例12: processImageResponse

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private void processImageResponse(String id, ImageResponse response) {
    if (response != null) {
        Bitmap bitmap = response.getBitmap();
        if (bitmap != null) {
            BitmapDrawable drawable = new BitmapDrawable(UserSettingsFragment.this.getResources(), bitmap);
            drawable.setBounds(0, 0,
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
            userProfilePic = drawable;
            userProfilePicID = id;
            connectedStateLabel.setCompoundDrawables(null, drawable, null, null);
            connectedStateLabel.setTag(response.getRequest().getImageUri());
        }
    }
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:16,代碼來源:UserSettingsFragment.java

示例13: createAndPutChipForUser

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
private ChipSpan createAndPutChipForUser(TLRPC.User user) {
    LayoutInflater lf = (LayoutInflater) ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    View textView = lf.inflate(R.layout.group_create_bubble, null);
    TextView text = (TextView) textView.findViewById(R.id.bubble_text_view);
    String name = UserObject.getUserName(user);
    if (name.length() == 0 && user.phone != null && user.phone.length() != 0) {
        name = PhoneFormat.getInstance().format("+" + user.phone);
    }
    text.setText(name + ", ");

    int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    textView.measure(spec, spec);
    textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
    Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(b);
    canvas.translate(-textView.getScrollX(), -textView.getScrollY());
    textView.draw(canvas);
    textView.setDrawingCacheEnabled(true);
    Bitmap cacheBmp = textView.getDrawingCache();
    Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true);
    textView.destroyDrawingCache();

    final BitmapDrawable bmpDrawable = new BitmapDrawable(b);
    bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight());

    SpannableStringBuilder ssb = new SpannableStringBuilder("");
    ChipSpan span = new ChipSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE);
    allSpans.add(span);
    selectedContacts.put(user.id, span);
    for (ImageSpan sp : allSpans) {
        ssb.append("<<");
        ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    userSelectEditText.setText(ssb);
    userSelectEditText.setSelection(ssb.length());
    return span;
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:38,代碼來源:DeleteBySelectContacts.java

示例14: getAndAddHoverView

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
/**
 * 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.
 */
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;
}
 
開發者ID:jpaijh,項目名稱:TYT,代碼行數:24,代碼來源:DynamicGridView.java

示例15: getAndAddHoverView

import android.graphics.drawable.BitmapDrawable; //導入方法依賴的package包/類
/**
 * 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.
 */
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;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:24,代碼來源:DynamicListView.java


注:本文中的android.graphics.drawable.BitmapDrawable.setBounds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。