java - Cyan bar appears above ImageView after downloading image from website in DialogFragment -


i tried downloading image file following address: http://i0.kym-cdn.com/photos/images/newsfeed/000/002/110/longcat.jpg

i using following setup:

mainactivity.java:

public class mainactivity     extends actionbaractivity {      @override     protected void oncreate(bundle savedinstancestate)     {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         if(savedinstancestate == null)         {             getsupportfragmentmanager().begintransaction().add(r.id.container, new placeholderfragment()).commit();         }     } } 

placeholderfragment.java:

public class placeholderfragment     extends fragment {     private button button;      public placeholderfragment()     {     }      @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate)     {         view rootview = inflater.inflate(r.layout.fragment_main, container, false);         button = (button)rootview.findviewbyid(r.id.fragment_main_button);         button.setonclicklistener(new view.onclicklistener()         {             @override             public void onclick(view v)             {                 new imagedownloadasynctask().execute("http://i0.kym-cdn.com/photos/images/newsfeed/000/002/110/longcat.jpg");             }         });         return rootview;     }       public class imagedownloadasynctask extends asynctask<string, void, byte[]>     {         @override         protected byte[] doinbackground(string... params)         {             if(params.length <= 0)             {                 return null;             }              byte[] imagedata = null;             string url = params[0];             httpurlconnection httpurlconnection = null;             try             {                 url address = new url(url);                 httpurlconnection = (httpurlconnection)address.openconnection();                 httpurlconnection.setrequestmethod("get");                 httpurlconnection.setdoinput(true);                 httpurlconnection.connect();                 if(httpurlconnection.getresponsecode() == 200)                 {                     bytearrayoutputstream bytearrayoutputstream = new bytearrayoutputstream();                     ioutils.copy(httpurlconnection.getinputstream(), bytearrayoutputstream);                     imagedata = bytearrayoutputstream.tobytearray();                 }                 else                 {                     return null;                 }             }             catch(malformedurlexception e)             {                 e.printstacktrace();             }             catch(ioexception e)             {                 e.printstacktrace();             }                         {                 if(httpurlconnection != null)                 {                     httpurlconnection.disconnect();                 }             }             return imagedata;         }          @override         protected void onpostexecute(byte[] bytes)         {             super.onpostexecute(bytes);             if(bytes != null) {                 imagedisplaydialogfragment imagedisplaydialogfragment = new imagedisplaydialogfragment();                 imagedisplaydialogfragment.settargetfragment(placeholderfragment.this, 0);                 bundle bundle = new bundle();                 bundle.putbytearray("imagedata", bytes);                 imagedisplaydialogfragment.setarguments(bundle);                 imagedisplaydialogfragment.show(getactivity().getsupportfragmentmanager(), imagedisplaydialogfragment.tag);             } else {                 toast.maketext(getactivity(), r.string.downloading_file_failed, toast.length_long).show();             }         }     }  } 

and imagedisplaydialogfragment.java:

public class imagedisplaydialogfragment extends dialogfragment {     private imageview imageview;      public static final string tag = imagedisplaydialogfragment.class.getname();      @override     public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate)     {         view view = inflater.inflate(r.layout.dialogfragment_imagedisplay, container, false);         imageview = (imageview)view.findviewbyid(r.id.dialog_imagedisplay_imageview);         byte[] imagedata = getarguments().getbytearray("imagedata");         bitmap bmp = bitmapfactory.decodebytearray(imagedata, 0, imagedata.length);         imageview.setminimumwidth(bmp.getwidth());         imageview.setminimumheight(bmp.getheight());         imageview.setimagebitmap(bmp);         return view;     } } 

so technically using asynctask download content of url byte array using commons-io, i'm sending byte array dialog fragment display in imageview.

the xml layout dialog fragment this:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"               android:orientation="vertical"               android:layout_width="wrap_content"               android:layout_height="wrap_content">     <imageview         android:id="@+id/dialog_imagedisplay_imageview"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:contentdescription="@string/longcat"         android:layout_centerinparent="true"/> </relativelayout> 

however, displays strange cyan line artifact above image, , imageview larger actual image itself.

image:

screenshot

where going wrong?

from screenshot provided, , fact it's dialogfragment, can safely presume blue line/space title bar of dialog (similar, different actionbar). in order disable this, there built-in method:

getdialog().getwindow().requestfeature(window.feature_no_title); 

this disable title bar of dialogfragment.

for more information, please refer docs.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -