I want to set a rounded corner on my ImageView and here is code:
FrameLayout frameLayout = new FrameLayout(this);
frameLayout.setLayoutParams(up);
layout.addView(frameLayout);
CardView cardView = new CardView(this);
cardView.setCardElevation(0);
cardView.setRadius(20);
cardView.setMaxCardElevation(0);
cardView.setLayoutParams(upz);
frameLayout.addView(cardView);
ImageView imageView = new ImageView(this);
String imageuri = listgambarpromo.get(i);
if (!this.isFinishing()) {
Glide.with(getBaseContext())
.load(imageuri)
.error(R.drawable.promoe)
.placeholder(R.drawable.promoe)
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.fitCenter()
.into(imageView);
}
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setLayoutParams(upz1);
cardView.addView(imageView);
I've set the ImageView inside the CardView, but it doesn't work and shown square on the corners
What should I do with my codes?
you already use Glide library for image. So there is make round option
Glide.with(context)
.load(url)
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(20)))
.into(imageView);
like this.
if you want to make circle,
RequestOptions options = new RequestOptions()
.circleCrop()
.placeholder(R.drawable.img_nonemymenu)
.error(R.drawable.img_nonemymenu);
Glide.with(mContext).setDefaultRequestOptions(options)
.load(url)
.circleCrop()
.into(imageView);
like this.
for more options, check this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.