2013-04-07 1 views
4

리프트 뷰의 각 행에 사용자 아이콘이 있습니다. 나는 하나의 모서리를 둥글게하고 싶습니다. 여기에 내가 가지고는 아무것도하지 않습니다 무엇 :ListView 행의 ImageView에 둥근 모서리가 있습니다.

<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_pic_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> 

답변

13

당신은 유니버설 이미지 로더를 사용할 수 있습니다.

https://github.com/nostra13/Android-Universal-Image-Loader.

둥근 모서리가있는 비트 맵을 표시하는 데 사용할 수 있습니다. 위의 링크를 확인하십시오. 당신은 당신의 필요에 따라 다른 옵션을 구성 할 수 있습니다

ImageView image=(ImageView)vi.findViewById(R.id.imageview); 
imageLoader.displayImage(imageurl, image,options);//provide imageurl, imageview and options 

사용자 정의 어댑터 생성자 당신의 getView에서

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(); 

()에서

. http://www.curious-creature.org/2012/12/11/android-recipe-1-image-with-rounded-corners/

@ 모서리가 둥근

로맹 사람 이미지 How to make an ImageView with rounded corners?

http://ruibm.com/?p=184 @ 아래 발견.

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; 
} 
} 
+0

getRoundedCornerBitmap() 메소드는 내가 –

+1

안녕을 찾고 있었다, 어떻게 왼쪽 반올림하지 않도록 이미지의 우측 상단과 오른쪽 buttom의 작업을 수행하는 말해 줄 수 있습니까? –

+0

@SampathKumar, 새로운 질문을해야합니다. 또한 이것이 도움이되는지 확인하십시오 : http://stackoverflow.com/questions/15962745/draw-a-semicircle-in-the-background-of-a-view 또는 http://developer.android.com/ reference/android/graphics/Canvas.html – dwbrito

관련 문제