2016-06-10 22 views
0

Ich bekomme merkwürdige Probleme beim Laden von Bildern mit Universal Image Loader. Ich möchte das Bild mit allen abgerundeten Ecken anzeigen, aber das Ausgabebild wird nicht nach Bedarf angezeigt.Image-Ecken werden nicht abgerundet, wenn Universal Image Loader verwendet wird

Unten ist mein Code in XML-Adapter Artikel -

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:id="@+id/container_rl" 
    android:background="@color/transparent_color" 
    android:layout_height="300dp"> 

<ImageView 
    android:id="@+id/object_iv" 
    android:scaleType="fitXY" 
    android:adjustViewBounds="true" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

<View 
    android:background="@drawable/rounded_corner_bg" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

<TextView 
    android:id="@+id/name_tv" 
    android:layout_centerInParent="true" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:layout_marginLeft="@dimen/space_20" 
    android:layout_marginRight="@dimen/space_20" 
    android:text="@string/app_name" 
    android:textColor="@color/white" 
    android:textSize="@dimen/size_18"/> 
</RelativeLayout> 

Hier Code in Adapter -

ImageLoaderUniversal.ImageLoadWithRoundedCorners(mContext,ImageURI, mFeedIV); 

und zuletzt Code für Last Bild -

public static void ImageLoadWithRoundedCorners(Context mContext,final String URl, final ImageView imageView){ 
    DisplayImageOptions options = new DisplayImageOptions.Builder() 
      .showImageOnLoading(R.mipmap.ic_default_media) 
      .showImageForEmptyUri(R.mipmap.ic_default_media) 
      .showImageOnFail(R.mipmap.ic_default_media) 
      .cacheOnDisk(true) 
      .displayer(new RoundedBitmapDisplayer(25)) 
      .build(); 

    ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(mContext).defaultDisplayImageOptions(
      options).memoryCache(new WeakMemoryCache()); 
    ImageLoaderConfiguration config = builder.build(); 
    imageLoader = ImageLoader.getInstance(); 
    if (!imageLoader.isInited()) { 
     imageLoader.init(config.createDefault(mContext)); 
    } 
    imageLoader.displayImage(URl, imageView, options); 
} 

hier hinzufügen ist scrren shot angehängt davon, wie Bilder mit dem obigen Code angezeigt werden.

Bitte geben Sie Ihre Lösung zu meinem Problem.

TIA

Antwort

0

Try This

options = new DisplayImageOptions.Builder() 
    .displayer(new RoundedBitmapDisplayer(50)) 
    .showStubImage(R.drawable.ic_app) 
    .showImageForEmptyUri(R.drawable.camera) 
    .showImageOnFail(R.drawable.ic_error) 
    .cacheOnDisc() 
    .build(); 
+0

Versuchte und gleiche Ergebnis – Ravi

0

Bitte kompilieren Sie es in Ihre Abhängigkeiten und unten XML-Code anstelle von Imageview verwenden.

Kompilierung 'de.hdodenhof: circleimageview: 2.0.0'

<de.hdodenhof.circleimageview.CircleImageView 
         android:id="@+id/ivUserImage_nfp" 
         android:layout_width="60dp" 
         android:layout_height="60dp" 
         android:src="@drawable/profile_img" 
         app:civ_border_color="@color/textcolor" 
         app:civ_border_width="1dp" /> 

eingestellten Grenze Farbe und Breite nach Ihren Bedürfnissen. Verwenden Sie den universellen Image-Loader nur zum Laden von Bildern.

+0

ich nicht Ich möchte ein rundes Bild zeigen, ich brauche nur abgerundete Ecken – Ravi

0

Ich benutze Universal-Bild loader Bibliothek zum Herunterladen und um die Ecken des Bildes, und es funktionierte für mich

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(thisContext) 
      // You can pass your own memory cache implementation 
      .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) 
      .build(); 

DisplayImageOptions options = new DisplayImageOptions.Builder() 
      .displayer(new RoundedBitmapDisplayer(10)) //rounded corner bitmap 
      .cacheInMemory(true) 
      .cacheOnDisc(true) 
      .build(); 

ImageLoader imageLoader = ImageLoader.getInstance(); 
imageLoader.init(config); 
imageLoader.displayImage(image_url,image_view, options); 

Weitere Referenz refereImageView rounded corners