本文整理匯總了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));
}
示例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());
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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();
}
示例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);
}
示例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);
}