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


Java RoundedBitmapDrawable.setCircular方法代碼示例

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


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

示例1: bind

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
public void bind(Party party, int position) {
    //make the image circular
    //make the image circular
    if (!TextUtils.isEmpty(party.getPicturePath())) {
        RoundedBitmapDrawable bitmapDrawable = RoundedBitmapDrawableFactory.create(
                getContext().getResources(),
                party.getPicturePath());

        bitmapDrawable.setCircular(true);
        picImageView.setImageDrawable(bitmapDrawable);
    } else {
        picImageView.setImageResource(R.drawable.default_party_pic);
    }

    partyNameTV.setText(party.getName());

    double balance = party.calculateBalances();
    balanceTV.setText(UtilsFormat.formatCurrency(balance, getContext()));
    balanceTV.setTextColor(getContext().getResources().getColor(balance < 0 ? R.color.red_medium : R.color.green_medium));
}
 
開發者ID:ndhunju,項目名稱:dailyJournal,代碼行數:21,代碼來源:PartyCardAdapter.java

示例2: setPartyViews

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
private void setPartyViews(Party party){

        //make the image circular
        //make the image circular
        if (!TextUtils.isEmpty(mParty.getPicturePath())) {
            RoundedBitmapDrawable bitmapDrawable = RoundedBitmapDrawableFactory.create(
                    getResources(),
                    mParty.getPicturePath());

            bitmapDrawable.setCircular(true);
            picIV.setImageDrawable(bitmapDrawable);
        } else {
            picIV.setImageResource(R.drawable.default_party_pic);
        }

        nameTV.setText(party.getName());

        balanceTV.setText(UtilsFormat.formatCurrency(party.calculateBalances(), getActivity()));
        balanceTV.setTextColor(getResources().getColor(party.calculateBalances() < 0 ? R.color.red_medium : R.color.green_medium));

        getActivity().setTitle(mParty.getName());

    }
 
開發者ID:ndhunju,項目名稱:dailyJournal,代碼行數:24,代碼來源:PartyDetailFragment.java

示例3: clipToRound

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
/**
 * 把 Bitmap 變圓。
 *
 * @param context Context
 * @param bitmap 要處理的 Bitmap
 * @return 圓形的 Bitmap
 */
public static Bitmap clipToRound(Context context, Bitmap bitmap) {
    final RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap);
    drawable.setAntiAlias(true);
    drawable.setCircular(true);
    drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());

    bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    drawable.draw(canvas);

    return bitmap;
}
 
開發者ID:RikkaApps,項目名稱:FCM-for-Mojo,代碼行數:20,代碼來源:ChatIcon.java

示例4: get

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
static RoundedBitmapDrawable get(Activity activity, Uri thumbnail) {

        RoundedBitmapDrawable dr = null;

        try {
            Bitmap bitmap = MediaStore.Images.Media.getBitmap(activity.getContentResolver(), thumbnail);
            dr = RoundedBitmapDrawableFactory.create(activity.getResources(), bitmap);
            dr.setCircular(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dr;
    }
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:14,代碼來源:RoundedContact.java

示例5: makeCircle

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
public static Bitmap makeCircle(Bitmap bitmap) {
    RoundedBitmapDrawable roundedPhoto = RoundedBitmapDrawableFactory.create(Resources
            .getSystem(), bitmap);

    roundedPhoto.setCircular(true);

    return roundedPhoto.getBitmap();
}
 
開發者ID:a-deda,項目名稱:share-location,代碼行數:9,代碼來源:PhotoFixer.java

示例6: setImageDrawable

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
@Override
public void setImageDrawable(Drawable drawable) {
    Bitmap bitmap = drawableToBitmap(drawable);
    RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(getResources(), bitmap);
    d.setCircular(true);
    super.setImageDrawable(d);
}
 
開發者ID:gvinciguerra,項目名稱:custode,代碼行數:8,代碼來源:RoundedContactBadge.java

示例7: TransformToRounded

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
public static Bitmap TransformToRounded(Bitmap source, Context mContext, int width, int heigth) {
    // Create the RoundedBitmapDrawable.
    RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), source);
    drawable.setCircular(true);
    //drawable.setCornerRadius(mContext.getCornerRadius(source));
    Bitmap output = Bitmap.createBitmap(width, heigth, source.getConfig());
    Canvas canvas = new Canvas(output);
    drawable.setAntiAlias(true);
    drawable.setBounds(0, 0, width, heigth);
    drawable.draw(canvas);
    if (source != output) {
        source.recycle();
    }
    return output;
}
 
開發者ID:malah-code,項目名稱:Open-Quran-Radio,代碼行數:16,代碼來源:ImageHelper.java

示例8: setRoundImage

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
void setRoundImage(ImageView view,int id){

        Bitmap bitmap = BitmapFactory.decodeResource(this.getResources(),id);
        RoundedBitmapDrawable roundedBitmapDrawable= RoundedBitmapDrawableFactory.create(getResources(),bitmap);
        roundedBitmapDrawable.setCornerRadius(2.0f);
        roundedBitmapDrawable.setCircular(true);
        view.setImageDrawable(roundedBitmapDrawable);

    }
 
開發者ID:appteam-nith,項目名稱:Hillffair,代碼行數:10,代碼來源:ThemeSelectionActivity.java

示例9: roundedBitmap

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
public static Drawable roundedBitmap(Bitmap bitmap) {
    RoundedBitmapDrawable circleDrawable = RoundedBitmapDrawableFactory.create(App.getInstance().getResources(), bitmap);
    circleDrawable.getPaint().setAntiAlias(true);
    circleDrawable.setCircular(true);
    circleDrawable.setCornerRadius(Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f);
    return circleDrawable;
}
 
開發者ID:shegang,項目名稱:meishiDemo,代碼行數:8,代碼來源:DrawableUtils.java

示例10: doInBackground

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
@Override
protected RoundedBitmapDrawable doInBackground(String... urlToScrape) {
    InputStream is = null;
    RoundedBitmapDrawable roundDrawable = null;
    try {
        is = (InputStream) new URL(urlToScrape[0]).getContent();
        roundDrawable = RoundedBitmapDrawableFactory.create(activity.getResources(), is);
        roundDrawable.setCircular(true);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return roundDrawable;
}
 
開發者ID:R-a-dio,項目名稱:R-a-dio-Amazing-Android-App,代碼行數:14,代碼來源:DJImageTask.java

示例11: setAvatarPreLollipop

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
private void setAvatarPreLollipop(@DrawableRes int resId) {
    Drawable drawable = ResourcesCompat.getDrawable(getResources(), resId,
            getContext().getTheme());
    BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
    @SuppressWarnings("ConstantConditions")
    RoundedBitmapDrawable roundedDrawable = RoundedBitmapDrawableFactory.create(getResources(),
            bitmapDrawable.getBitmap());
    roundedDrawable.setCircular(true);
    setImageDrawable(roundedDrawable);
}
 
開發者ID:vanpersie9987,項目名稱:android-topeka,代碼行數:11,代碼來源:AvatarView.java

示例12: bindImageView

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
@Override
public void bindImageView(ImageView imageView) {
    if (imageView != null) {
        RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(imageView.getResources(), avatar);
        circularBitmapDrawable.setCircular(true);
        imageView.setImageDrawable(circularBitmapDrawable);
    }
}
 
開發者ID:two-guys-one-code,項目名稱:TGOCMessagesActivity,代碼行數:9,代碼來源:TGOCAvatar.java

示例13: convertToCircularImageView

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
public static void convertToCircularImageView(ImageView v) {
        int backgroundColor = ((ColorDrawable) v.getBackground()).getColor();
        Bitmap bitmap = Bitmap.createBitmap(v.getLayoutParams().width, v.getLayoutParams().height, Bitmap.Config.ARGB_8888);
        bitmap.eraseColor(backgroundColor);

        // Replace drawable.
        RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(v.getResources(), bitmap);
        drawable.setCircular(true);
        v.setBackground(drawable);

        // Causing these log entries in 6.0:
        // Called getWidth() on a recycle()'d bitmap! This is undefined behavior!
        // Called getHeight() on a recycle()'d bitmap! This is undefined behavior!
//        bitmap.recycle();
    }
 
開發者ID:cpoppema,項目名稱:pass-mobile-android,代碼行數:16,代碼來源:ImageViewHelper.java

示例14: cropRoundedImageView

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
/**
 * Crop ImageView in parameter for create a circle
 */
private void cropRoundedImageView(ImageView imageView) {
    Bitmap imageBitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
    RoundedBitmapDrawable imageDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), imageBitmap);
    imageDrawable.setCircular(true);
    imageDrawable.setCornerRadius(Math.max(imageBitmap.getWidth(), imageBitmap.getHeight()) / 2.0f);
    imageView.setImageDrawable(imageDrawable);
}
 
開發者ID:Kunzisoft,項目名稱:RememBirthday,代碼行數:11,代碼來源:ContactAdapter.java

示例15: setResource

import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //導入方法依賴的package包/類
@Override
protected void setResource(Bitmap resource) {
    RoundedBitmapDrawable circularBitmapDrawable =
            RoundedBitmapDrawableFactory.create(mContext.getResources(), resource);
    circularBitmapDrawable.setCircular(true);
    getView().setImageDrawable(circularBitmapDrawable);
}
 
開發者ID:AndroidIasi,項目名稱:CodeCamp,代碼行數:8,代碼來源:CircleBitmapImageViewTarget.java


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