Android ListView行中ImageView上的圆角

Android ListView行中ImageView上的圆角,android,imageview,shape,Android,Imageview,Shape,我在电梯视图的每一行都有一个用户图标。我想要一个圆角。这是我所拥有的,但它没有任何作用: <ImageView android:background="@drawable/profile_widget_selector" android:id="@+id/ivTopUserPP" android:layout_width="65dp" android:layout_height="65dp" android:

我在电梯视图的每一行都有一个用户图标。我想要一个圆角。这是我所拥有的,但它没有任何作用:

 <ImageView
        android:background="@drawable/profile_widget_selector"
        android:id="@+id/ivTopUserPP"
        android:layout_width="65dp"
        android:layout_height="65dp"
        android:baselineAlignBottom="@drawable/profile_pic_shape"
        android:src="@drawable/usericon" />

profile\u pic\u shape.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <solid android:color="#bbbbbb" />

    <stroke
        android:width="1dp"
        android:color="#bbb" />

    <padding
        android:bottom="1dp"
        android:left="1dp"
        android:right="1dp"
        android:top="1dp" />

    <corners android:topLeftRadius="40dp" />

</shape>

您可以使用通用图像加载器

可用于显示具有圆角的位图。检查上面的链接

在自定义适配器构造函数中

 File cacheDir = StorageUtils.getOwnCacheDirectory(a, "your folder");

 // Get singletone instance of ImageLoader
 imageLoader = ImageLoader.getInstance();
 // Create configuration for ImageLoader (all options are optional)
 ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(a)
      // You can pass your own memory cache implementation
     .discCache(new UnlimitedDiscCache(cacheDir)) // You can pass your own disc cache implementation
     .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
     .enableLogging()
     .build();
  // Initialize ImageLoader with created configuration. Do it once.
  imageLoader.init(config);
  options = new DisplayImageOptions.Builder()
 .showStubImage(R.drawable.stub_id)//display stub image
 .cacheInMemory()
 .cacheOnDisc()
 .displayer(new RoundedBitmapDisplayer(20)) //rounded corner bitmap
 .build();
在getView()中

您可以配置其他选项以满足您的需要

带圆角的Romain guys图像@

找到下面的@


getRoundedCornerBitmap()方法是我一直在寻找的。嗨,你能告诉我如何使图像的右上角和右下角圆而不是左下角吗?@SampathKumar,你应该问一个新问题。此外,请检查这是否有助于您:,或
 ImageView image=(ImageView)vi.findViewById(R.id.imageview); 
 imageLoader.displayImage(imageurl, image,options);//provide imageurl, imageview and options
public class ImageHelper {
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap
            .getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    final float roundPx = pixels;

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}
}