Java Code Examples for android.support.v4.graphics.drawable.RoundedBitmapDrawable#setCornerRadius()
The following examples show how to use
android.support.v4.graphics.drawable.RoundedBitmapDrawable#setCornerRadius() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HistoryItemView.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void onLargeIconAvailable(Bitmap icon, int fallbackColor, boolean isFallbackColorDefault) { // TODO(twellington): move this somewhere that can be shared with bookmarks. if (icon == null) { mIconGenerator.setBackgroundColor(fallbackColor); icon = mIconGenerator.generateIconForUrl(getItem().getUrl()); mIconImageView.setImageDrawable(new BitmapDrawable(getResources(), icon)); } else { RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create( getResources(), Bitmap.createScaledBitmap(icon, mDisplayedIconSize, mDisplayedIconSize, false)); roundedIcon.setCornerRadius(mCornerRadius); mIconImageView.setImageDrawable(roundedIcon); } }
Example 2
Source File: FloatingView.java From FastAccess with GNU General Public License v3.0 | 6 votes |
public void setupImageView() { if (imageView != null) { String path = PrefHelper.getString(PrefConstant.CUSTOM_ICON); if (!InputHelper.isEmpty(path)) { path = Uri.decode(PrefHelper.getString(PrefConstant.CUSTOM_ICON)); boolean fileExists = new File(path).exists(); if (fileExists) { imageView.setImageDrawable(null); Bitmap src = BitmapFactory.decodeFile(path); if (src == null) { imageView.setImageResource(R.drawable.ic_app_drawer_icon); onMoving(false); return; } RoundedBitmapDrawable dr = RoundedBitmapDrawableFactory.create(getResources(), src); dr.setCornerRadius(Math.max(src.getWidth(), src.getHeight()) / 2.0f); imageView.setImageDrawable(dr); return; } } imageView.setImageResource(R.drawable.ic_app_drawer_icon); onMoving(false); } }
Example 3
Source File: TextCardView.java From leanback-showcase with Apache License 2.0 | 6 votes |
public void updateUi(Card card) { TextView extraText = (TextView) findViewById(R.id.extra_text); TextView primaryText = (TextView) findViewById(R.id.primary_text); final ImageView imageView = (ImageView) findViewById(R.id.main_image); extraText.setText(card.getExtraText()); primaryText.setText(card.getTitle()); // Create a rounded drawable. int resourceId = card.getLocalImageResourceId(getContext()); Bitmap bitmap = BitmapFactory .decodeResource(getContext().getResources(), resourceId); RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getContext().getResources(), bitmap); drawable.setAntiAlias(true); drawable.setCornerRadius( Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f); imageView.setImageDrawable(drawable); }
Example 4
Source File: NewTabPageView.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override public void onLargeIconAvailable( Bitmap icon, int fallbackColor, boolean isFallbackColorDefault) { if (icon == null) { mIconGenerator.setBackgroundColor(fallbackColor); icon = mIconGenerator.generateIconForUrl(mItem.getUrl()); mItemView.setIcon(new BitmapDrawable(getResources(), icon)); mItem.setTileType(isFallbackColorDefault ? MostVisitedTileType.ICON_DEFAULT : MostVisitedTileType.ICON_COLOR); } else { RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create( getResources(), icon); int cornerRadius = Math.round(ICON_CORNER_RADIUS_DP * getResources().getDisplayMetrics().density * icon.getWidth() / mDesiredIconSize); roundedIcon.setCornerRadius(cornerRadius); roundedIcon.setAntiAlias(true); roundedIcon.setFilterBitmap(true); mItemView.setIcon(roundedIcon); mItem.setTileType(MostVisitedTileType.ICON_REAL); } mSnapshotMostVisitedChanged = true; if (mIsInitialLoad) loadTaskCompleted(); }
Example 5
Source File: NoInternetDialog.java From NoInternetDialog with Apache License 2.0 | 6 votes |
private void initHalloweenTheme() { if (!isHalloween) { return; } Bitmap bmp = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.ground); RoundedBitmapDrawable dr = RoundedBitmapDrawableFactory.create(getContext().getResources(), bmp); dr.setCornerRadius(dialogRadius); dr.setAntiAlias(true); ground.setBackgroundDrawable(dr); plane.setImageResource(R.drawable.witch); tomb.setImageResource(R.drawable.tomb_hw); moon.setVisibility(View.VISIBLE); ground.setVisibility(View.VISIBLE); pumpkin.setVisibility(View.VISIBLE); wifiOn.getBackground().mutate().setColorFilter(ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH), PorterDuff.Mode.SRC_IN); mobileOn.getBackground().mutate().setColorFilter(ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH), PorterDuff.Mode.SRC_IN); airplaneOff.getBackground().mutate().setColorFilter(ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH), PorterDuff.Mode.SRC_IN); }
Example 6
Source File: CircleImageView.java From MediaNotification with Apache License 2.0 | 6 votes |
@Override public void onDraw(Canvas canvas) { if (bitmap != null) { int size = Math.min(canvas.getWidth(), canvas.getHeight()); if (size != this.size) { this.size = size; bitmap = ThumbnailUtils.extractThumbnail(bitmap, size, size); RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap); roundedBitmapDrawable.setCornerRadius(size / 2); roundedBitmapDrawable.setAntiAlias(true); bitmap = ImageUtils.drawableToBitmap(roundedBitmapDrawable); } canvas.drawBitmap(bitmap, 0, 0, paint); } }
Example 7
Source File: TileGroup.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onLargeIconAvailable( @Nullable Bitmap icon, int fallbackColor, boolean isFallbackColorDefault) { if (mTrackLoadTask) mObserver.onLoadTaskCompleted(); Tile tile = getTile(mUrl); if (tile == null) return; // The tile might have been removed. if (icon == null) { mIconGenerator.setBackgroundColor(fallbackColor); icon = mIconGenerator.generateIconForUrl(mUrl); tile.setIcon(new BitmapDrawable(mContext.getResources(), icon)); tile.setType(isFallbackColorDefault ? TileVisualType.ICON_DEFAULT : TileVisualType.ICON_COLOR); } else { RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create(mContext.getResources(), icon); int cornerRadius = Math.round(ICON_CORNER_RADIUS_DP * mContext.getResources().getDisplayMetrics().density * icon.getWidth() / mDesiredIconSize); roundedIcon.setCornerRadius(cornerRadius); roundedIcon.setAntiAlias(true); roundedIcon.setFilterBitmap(true); tile.setIcon(roundedIcon); tile.setType(TileVisualType.ICON_REAL); } mObserver.onTileIconChanged(tile); }
Example 8
Source File: BookmarkItemRow.java From delion with Apache License 2.0 | 5 votes |
@Override public void onLargeIconAvailable(Bitmap icon, int fallbackColor) { if (icon == null) { mIconGenerator.setBackgroundColor(fallbackColor); icon = mIconGenerator.generateIconForUrl(mUrl); mIconImageView.setImageDrawable(new BitmapDrawable(getResources(), icon)); } else { RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create( getResources(), Bitmap.createScaledBitmap(icon, mDisplayedIconSize, mDisplayedIconSize, false)); roundedIcon.setCornerRadius(mCornerRadius); mIconImageView.setImageDrawable(roundedIcon); } }
Example 9
Source File: BookmarkItemRow.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onLargeIconAvailable( Bitmap icon, int fallbackColor, boolean isFallbackColorDefault) { if (icon == null) { mIconGenerator.setBackgroundColor(fallbackColor); icon = mIconGenerator.generateIconForUrl(mUrl); mIconImageView.setImageDrawable(new BitmapDrawable(getResources(), icon)); } else { RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create( getResources(), Bitmap.createScaledBitmap(icon, mDisplayedIconSize, mDisplayedIconSize, false)); roundedIcon.setCornerRadius(mCornerRadius); mIconImageView.setImageDrawable(roundedIcon); } }
Example 10
Source File: AndroidNotifications.java From actor-platform with GNU Affero General Public License v3.0 | 5 votes |
@NotNull private RoundedBitmapDrawable getRoundedBitmapDrawable(FileSystemReference reference) { Bitmap b = BitmapFactory.decodeFile(reference.getDescriptor()); RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(context.getResources(), Bitmap.createScaledBitmap(b, Screen.dp(55), Screen.dp(55), false)); d.setCornerRadius(d.getIntrinsicHeight() / 2); d.setAntiAlias(true); return d; }
Example 11
Source File: DrawableUtils.java From meiShi with Apache License 2.0 | 5 votes |
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; }
Example 12
Source File: AppIconView.java From Cleaner with Apache License 2.0 | 5 votes |
private Bitmap getRoundBitmap(@DrawableRes int drawable, int size) { Bitmap bitmap = ImageUtils.drawableToBitmap(ContextCompat.getDrawable(getContext(), drawable)); bitmap = Bitmap.createBitmap(bitmap, bitmap.getWidth() / 6, bitmap.getHeight() / 6, (int) (0.666 * bitmap.getWidth()), (int) (0.666 * bitmap.getHeight())); bitmap = ThumbnailUtils.extractThumbnail(bitmap, size, size); RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap); roundedBitmapDrawable.setCornerRadius(size / 2); roundedBitmapDrawable.setAntiAlias(true); return ImageUtils.drawableToBitmap(roundedBitmapDrawable); }
Example 13
Source File: BookmarkItemRow.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void onLargeIconAvailable( Bitmap icon, int fallbackColor, boolean isFallbackColorDefault) { if (icon == null) { mIconGenerator.setBackgroundColor(fallbackColor); icon = mIconGenerator.generateIconForUrl(mUrl); mIconImageView.setImageDrawable(new BitmapDrawable(getResources(), icon)); } else { RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create( getResources(), Bitmap.createScaledBitmap(icon, mDisplayedIconSize, mDisplayedIconSize, false)); roundedIcon.setCornerRadius(mCornerRadius); mIconImageView.setImageDrawable(roundedIcon); } }
Example 14
Source File: ConfirmImportantSitesDialogFragment.java From AndroidChromium with Apache License 2.0 | 5 votes |
private Drawable getFaviconDrawable(Bitmap icon, int fallbackColor, String url) { if (icon == null) { mIconGenerator.setBackgroundColor(fallbackColor); icon = mIconGenerator.generateIconForUrl(url); return new BitmapDrawable(getResources(), icon); } else { RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create(getResources(), Bitmap.createScaledBitmap(icon, mFaviconSize, mFaviconSize, false)); roundedIcon.setCornerRadius(mCornerRadius); return roundedIcon; } }
Example 15
Source File: CharacterCardView.java From leanback-showcase with Apache License 2.0 | 5 votes |
public void updateUi(Card card) { TextView primaryText = (TextView) findViewById(R.id.primary_text); final ImageView imageView = (ImageView) findViewById(R.id.main_image); primaryText.setText(card.getTitle()); if (card.getLocalImageResourceName() != null) { int resourceId = card.getLocalImageResourceId(getContext()); Bitmap bitmap = BitmapFactory .decodeResource(getContext().getResources(), resourceId); RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getContext().getResources(), bitmap); drawable.setAntiAlias(true); drawable.setCornerRadius(Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f); imageView.setImageDrawable(drawable); } }
Example 16
Source File: CircleImageView.java From AppCompat-Extension-Library with Apache License 2.0 | 5 votes |
/** * Helper for creating a circle bitmap drawable using the {@link android.support.v4.graphics.drawable.RoundedBitmapDrawable} * * @param bitmap The bitmap which should be converted to a circle bitmap drawable * @return the {@link android.support.v4.graphics.drawable.RoundedBitmapDrawable} containing the bitmap */ public static RoundedBitmapDrawable getCircleBitmapDrawable(Context context, Bitmap bitmap) { RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap); drawable.setCornerRadius(Math.max(bitmap.getWidth() / 2, bitmap.getHeight() / 2)); drawable.setAntiAlias(true); return drawable; }
Example 17
Source File: ContactAdapter.java From RememBirthday with GNU General Public License v3.0 | 5 votes |
/** * 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); }
Example 18
Source File: RoundedImageListener.java From attendee-checkin with Apache License 2.0 | 5 votes |
@Override public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) { if (response.getBitmap() != null) { Bitmap src = response.getBitmap(); RoundedBitmapDrawable avatar = RoundedBitmapDrawableFactory.create( mImageView.getResources(), src); avatar.setCornerRadius(Math.max(src.getWidth(), src.getHeight()) / 2.0f); mImageView.setImageDrawable(avatar); } else if (mDefaultImageResId != 0) { mImageView.setImageResource(mDefaultImageResId); } }
Example 19
Source File: MainActivity.java From Password-Storage with MIT License | 5 votes |
private RoundedBitmapDrawable createRoundedBitmapImageDrawableWithBorder(Bitmap bitmap){ int bitmapWidthImage = bitmap.getWidth(); int bitmapHeightImage = bitmap.getHeight(); int borderWidthHalfImage = 4; int bitmapRadiusImage = Math.min(bitmapWidthImage,bitmapHeightImage)/2; int bitmapSquareWidthImage = Math.min(bitmapWidthImage,bitmapHeightImage); int newBitmapSquareWidthImage = bitmapSquareWidthImage+borderWidthHalfImage; Bitmap roundedImageBitmap = Bitmap.createBitmap(newBitmapSquareWidthImage,newBitmapSquareWidthImage,Bitmap.Config.ARGB_8888); Canvas mcanvas = new Canvas(roundedImageBitmap); mcanvas.drawColor(Color.RED); int i = borderWidthHalfImage + bitmapSquareWidthImage - bitmapWidthImage; int j = borderWidthHalfImage + bitmapSquareWidthImage - bitmapHeightImage; mcanvas.drawBitmap(bitmap, i, j, null); Paint borderImagePaint = new Paint(); borderImagePaint.setStyle(Paint.Style.STROKE); borderImagePaint.setStrokeWidth(borderWidthHalfImage*2); borderImagePaint.setColor(Color.GRAY); mcanvas.drawCircle(mcanvas.getWidth()/2, mcanvas.getWidth()/2, newBitmapSquareWidthImage/2, borderImagePaint); RoundedBitmapDrawable roundedImageBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(),roundedImageBitmap); roundedImageBitmapDrawable.setCornerRadius(bitmapRadiusImage); roundedImageBitmapDrawable.setAntiAlias(true); return roundedImageBitmapDrawable; }
Example 20
Source File: ContactHolder.java From actor-platform with GNU Affero General Public License v3.0 | 4 votes |
private RoundedBitmapDrawable getRoundedBitmapDrawable(Context context, Bitmap b) { RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(context.getResources(), Bitmap.createScaledBitmap(b, Screen.dp(48), Screen.dp(48), false)); d.setCornerRadius(d.getIntrinsicHeight() / 2); d.setAntiAlias(true); return d; }