imageview - Best way to display an image from server in android -


i trying display image in android. image needs taken server. should best approach making sure image stored @ server fits android device screens. in image displaying xml need display textview (below image) giving brief description image. have create image specific height , width or there other approach?

you should store large enough image on server.

// know required width of image url url = new url(remotepath); urlconnection urlconnection = url.openconnection(); urlconnection.connect(); inputstream = (inputstream) urlconnection.getcontent(); bitmapfactory.options options = new bitmapfactory.options(); options.injustdecodebounds = true; bitmapfactory.decodestream(inputstream, options); int height = options.outheight; int width = options.outwidth; int samplesize = requiredwidth / width; // calculate how want sample images can keep memory small options.insamplesize = samplesize; options.injustdecodebounds = false; bitmap bitmap = bitmapfactory.decodestream(inputstream, options); imageview.setimagebitmap(bitmap); 

hope helps.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -