android - Image doesn't fit ImageView width and height in ViewPager -


i getting pictures facebook, biggest resolution there is. around 900 height , 500 width. using view pager displaying 6 of them in there. that, use image loader since save url of images.

i display them in imageview 300 width , 243 height. issue don't fill mentioned size. take half of place of cases.

sure, can use scaletype : centercrop achieve that, profile pictures, output ugly.

i explanation why doesn't work way want to. thank you! here's of code :

public class userprofileadapter extends fragmentstatepageradapter {     private list<string> userimages;      public userprofileadapter(fragmentmanager c, list<string> images){         super(c);         userimages = images;     }     @override     public int getcount() {         return userimages.size();     }      @override     public fragment getitem(int position) {         switch(position) {             case 0: return userprofilepictureitem.newinstance(userimages.get(position));             case 1: return userprofilepictureitem.newinstance(userimages.get(position));             case 2: return userprofilepictureitem.newinstance(userimages.get(position));             case 3: return userprofilepictureitem.newinstance(userimages.get(position));             case 4: return userprofilepictureitem.newinstance(userimages.get(position));             case 5: return userprofilepictureitem.newinstance(userimages.get(position));         }         return null;     } }    public class userprofilepictureitem extends fragment {     public userprofilepictureitem() {         //empty constructor     }      @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {         view rootview = inflater.inflate(                 r.layout.layout_user_profile_pic, container, false);         bundle args = getarguments();         string pic_url = args.getstring("pic_url");          displayimageoptions options = new displayimageoptions.builder()                 .showimageonloading(r.drawable.btn_blue)                 .showimageforemptyuri(r.drawable.btn_blue)                 .showimageonfail(r.drawable.btn_blue)                 .cacheondisk(true)                 .cacheinmemory(true)                 .imagescaletype(imagescaletype.exactly)                 .considerexifparams(true)                 .displayer(new simplebitmapdisplayer())                 .build();          imageview imageview = (imageview) rootview.findviewbyid(r.id.profile_user_pic);         imageloader.getinstance().displayimage(pic_url, imageview, options);         return rootview;     }      public static userprofilepictureitem newinstance(string picture_url) {         userprofilepictureitem fragment = new userprofilepictureitem();         bundle args = new bundle();         args.putstring("pic_url", picture_url);         fragment.setarguments(args);         return fragment;     } } 

and xml :

<?xml version="1.0" encoding="utf-8"?>  <relativelayout  xmlns:android="http://schemas.android.com/apk/res/android"      android:layout_width="wrap_content"      android:layout_height="wrap_content">      <imageview xmlns:android="http://schemas.android.com/apk/res/android"        android:layout_width="300dp"        android:layout_height="243dp"        android:id="@+id/profile_user_pic"        android:scaletype="centercrop"/> </relativelayout> 

change

android:scaletype="centercrop"

to

android:scaletype="fitxy" fits imageview.

but notice way destruct image doesn't keep ratio

otherwise change android:scaletype="fitcenter"


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -