2014-04-18 5 views
3

이미지 모양을 둥근 모양으로 표시하고 싶다는 의미에서 안드로이드 응용 프로그램을 만들었습니다.이미지가 올바르게 표시되지 않음 ImageView에

이미지 뷰에서 이미지가 제대로 표시되지 않습니다.

내 코드는 크기의 예 -

원본 이미지 IS-를 들어

int rounded_value = 168; 
DisplayImageOptions options = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).displayer(new RoundedBitmapDisplayer(rounded_value)).build(); 
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).defaultDisplayImageOptions(options).build(); 
ImageLoader.getInstance().init(config); 
ImageLoader.getInstance().displayImage(photourl, imageView, options); 

168 * 168

168*168

이다 - 이것도 내가 출력을 같이하는 이미지 뷰의 크기를 얻을 수 은 85 * 85

,485,

내가

85*85

+1

자른 반환이 정의 ImageeView https : //로 GitHub의 .com/vinc3m1/RoundedImageView –

+0

@BirajZalavadia RoundedImageView.jar 파일을 얻는 방법 –

+0

@AnjaliPandya 그것을 사용할 필요가 없습니다. 내 대답을 참조하십시오 http://stackoverflow.com/questions/18378741/how-to-make-an-imageview-in-circular-shape/18378873#18378873 – Piyush

답변

0

같은 - 출력이 시도하고자, 그 날 위해 일

public static Bitmap getCroppedBitmap(Bitmap bmp, int radius) 
{ 
    Bitmap sbmp; 
    if (bmp.getWidth() != radius || bmp.getHeight() != radius) 
     sbmp = Bitmap.createScaledBitmap(bmp, radius, radius, false); 
    else 
     sbmp = bmp; 
    Bitmap output = Bitmap.createBitmap(sbmp.getWidth(), sbmp.getHeight(), Config.ARGB_8888); 
    Canvas canvas = new Canvas(output); 

    final int color = 0xffa19774; 
    final Paint paint = new Paint(); 
    final Rect rect = new Rect(0, 0, sbmp.getWidth(), sbmp.getHeight()); 

    paint.setAntiAlias(true); 
    paint.setFilterBitmap(true); 
    paint.setDither(true); 
    canvas.drawARGB(0, 0, 0, 0); 
    paint.setColor(Color.parseColor("#BAB399")); 
    canvas.drawCircle(sbmp.getWidth()/2 + 0.7f, sbmp.getHeight()/2 + 0.7f, sbmp.getWidth()/2 + 0.1f, paint); 
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); 
    canvas.drawBitmap(sbmp, rect, rect, paint); 

    return output; 
} 
0

사용자 마스크 이미지보기 : http://goo.gl/w2LrM0

이미지보기 XML에서, 마스크를 제공 선언, 모양 타원을 가진 drawable xml로.

둥근 모양에 이미지 자르기를 적용 할 필요가 없습니다. 레이아웃

이미지보기 위젯 :

<com.android.BezelImageView 
// required properties, to getexact circle height should be equat to width 
app:maskDrawable="@drawable/round_mask" /> 

round_mask.xml :

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
     <shape android:shape="oval"> 
      <solid android:color="#000000" /> 
     </shape> 
    </item> 
</layer-list> 
0

이 기능은 둥근 시도 비트 맵을

public Bitmap getCroppedBitmap(Bitmap bitmap) { 
     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()); 

     paint.setAntiAlias(true); 
     canvas.drawARGB(0, 0, 0, 0); 
     paint.setColor(color); 
     // canvas.drawRoundRect(rectF, roundPx, roundPx, paint); 
     canvas.drawCircle(bitmap.getWidth()/2, bitmap.getHeight()/2, 
       bitmap.getWidth()/2, paint); 
     paint.setXfermode(`n`ew PorterDuffXfermode(Mode.SRC_IN)); 
     canvas.drawBitmap(bitmap, rect, rect, paint); 
     // Bitmap _bmp = Bitmap.createScaledBitmap(output, 60, 60, false); 
     // return _bmp; 
     return output; 
} 
관련 문제