Questions tagged [imageview]

Android widget that displays an arbitrary image or drawable, such as an icon.

9865 questions
704
votes
58 answers

How to make an ImageView with rounded corners?

In Android, an ImageView is a rectangle by default. How can I make it a rounded rectangle (clip off all 4 corners of my Bitmap to be rounded rectangles) in the ImageView? Note that from 2021 onwards, simply use ShapeableImageView
michael
  • 106,540
  • 116
  • 246
  • 346
572
votes
23 answers

How to load an ImageView by URL in Android?

How do you use an image referenced by URL in an ImageView?
Praveen
  • 90,477
  • 74
  • 177
  • 219
571
votes
29 answers

How to set tint for an image view programmatically in android?

Need to set tint for an image view... I am using it the following way: imageView.setColorFilter(R.color.blue,android.graphics.PorterDuff.Mode.MULTIPLY); But it doesn't change...
user2968768
380
votes
18 answers

Border for an Image view in Android?

How can I set a border for an ImageView and change its color in Android?
Praveen
  • 90,477
  • 74
  • 177
  • 219
348
votes
15 answers

Show Image View from file path?

I need to show an image by using the file name only, not from the resource id. ImageView imgView = new ImageView(this); imgView.setBackgroundResource(R.drawable.img1); I have the image img1 in the drawable folder. I wish to show that image from the…
Alex
  • 16,375
  • 7
  • 22
  • 19
324
votes
7 answers

Get Bitmap attached to ImageView

Given ImageView image = R.findViewById(R.id.imageView); image.setImageBitmap(someBitmap); Is it possible to retrieve the bitmap?
lemon
  • 9,155
  • 7
  • 39
  • 47
324
votes
8 answers

Changing ImageView source

I have an ImageView with a source image set in the xml using the following syntax: Now I need to change this image…
nourdine
  • 7,407
  • 10
  • 46
  • 58
294
votes
31 answers

ImageView in circular through XML

I'd Like to make any image from my ImageView to be circular with a border. I searched but couldn't find any useful information (anything that I tried didn't work). How can I achieve this through XML: Create an ImageView with certain src and make it…
user3050910
  • 3,107
  • 3
  • 13
  • 11
256
votes
1 answer

How to create a circular ImageView in Android?

How could I create a rounded ImageView in Android? I have tried the following code, but it's not working fine. Code: Bitmap circleBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); BitmapShader shader =…
user2134412
238
votes
16 answers

Scale Image to fill ImageView width and keep aspect ratio

I have a GridView. The data of GridView is request from a server. Here is the item layout in GridView:
Joe
  • 3,581
  • 4
  • 23
  • 28
236
votes
10 answers

How to convert a Base64 string into a Bitmap image to show it in a ImageView?

I have a Base64 String that represents a BitMap image. I need to transform that String into a BitMap image again to use it on a ImageView in my Android app How to do it? This is the code that I use to transform the image into the base64 String:…
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
209
votes
13 answers

How can I get zoom functionality for images?

Is there a common way to show a big image and enable the user to zoom in and out and pan the image? Until now I found two ways: overwriting ImageView, that seems a little bit too much for such a common problem. using a webview but with less…
Janusz
  • 187,060
  • 113
  • 301
  • 369
204
votes
16 answers

How to set margin of ImageView using code, not xml

I want to add an unknown number of ImageView views to my layout with margin. In XML, I can use layout_margin like this: There is ImageView.setPadding(), but no…
Bruce Lee
  • 3,049
  • 3
  • 20
  • 13
197
votes
20 answers

Fit image into ImageView, keep aspect ratio and then resize ImageView to image dimensions?

How to fit an image of random size to an ImageView? When: Initially ImageView dimensions are 250dp * 250dp The image's larger dimension should be scaled up/down to 250dp The image should keep its aspect ratio The ImageView dimensions should match…
jul
  • 36,404
  • 64
  • 191
  • 318
189
votes
27 answers

Android: Rotate image in imageview by an angle

I am using the following code to rotate a image in ImageView by an angle. Is there any simpler and less complex method available. ImageView iv = (ImageView)findViewById(imageviewid); TextView tv = (TextView)findViewById(txtViewsid); Matrix mat = new…
rijinrv
  • 2,029
  • 2
  • 16
  • 17
1
2 3
99 100