Tag Archives: ImageView

RoundedImageView – Android

round-white-label-l

This is a library which consist of a RoundedImageView. This is a hassle free light weight ImageView that you can use for user profiles and other needs.

This can be integrated in your Android Studio project using this Gradle integration

compile 'com.pathofacoder.roundedimageview:roundedimageview:0.1.0'

Library can be found here – https://bintray.com/batzee/maven/RoundedImageView/view

This project is made Open Source under the Apache 2.0 license, so you can help improve the library by contributing here
https://github.com/Batzee/Android-RoundedImageView

A small sample will be added soon…

Advertisements

Adding Images to Image View through Image URL – Android

ImageView img = (ImageView) findViewById(R.id.imageview1);

try {
URL url = new URL("your image url here");
//try this url :- http://0.tqn.com/d/webclipart/1/0/5/l/4/floral-icon-5.jpg

HttpGet httpRequest = null;
httpRequest = new HttpGet(url.toURI());
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient
.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
InputStream input = b_entity.getContent();
Bitmap bitmap = BitmapFactory.decodeStream(input);
img.setImageBitmap(bitmap);
}
catch (Exception ex) {

Toast t2 = Toast.makeText(getApplicationContext(),
                "Image Loading Failed", Toast.LENGTH_LONG);
        t2.setGravity(Gravity.CENTER, 0, 0);
        t2.show();
}

Here we are getting the image from the url as a InputStream, and converting it to Bitmap and feeding into the
ImageView img. If there was any error the toast message will display the message “Image Loading Failed”.

Hope you guys understood it

Download Sample Project