本文整理汇总了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);
}