Android widget that displays an arbitrary image or drawable, such as an icon.
Questions tagged [imageview]
9865 questions
99
votes
11 answers
Custom ImageView with drop shadow
Okay, I've been reading and searching around, and am now banging my head against the wall trying to figure this out. Here's what I have so far:
package com.pockdroid.sandbox;
import android.content.Context;
import android.graphics.Canvas;
import…

Kevin Coppock
- 133,643
- 45
- 263
- 274
94
votes
11 answers
ImageView scaling TOP_CROP
I have an ImageView which is displaying a png that has a bigger aspect ratio than that of the device (vertically speaking - meaning its longer). I want to display this while maintaining aspect ratio, matching the width of the parent, and pinning the…

Dori
- 18,283
- 17
- 74
- 116
93
votes
9 answers
Android fade in and fade out with ImageView
I'm having some troubles with a slideshow I'm building.
I've created 2 animations in xml for fade in and fade out:
fadein.xml
…

IPValverde
- 2,019
- 2
- 21
- 38
89
votes
28 answers
How can I give an imageview click effect like a button on Android?
I have imageview in my Android app that I am using like a button with the onClick event given, but as you might guess it is not giving imageview a clickable effect when clicked. How can I achieve that?

Burak Dede
- 3,725
- 5
- 40
- 53
87
votes
8 answers
Android ImageView scale smaller image to width with flexible height without cropping or distortion
Often asked, never answered (at least not in a reproducible way).
I have an image view with an image that is smaller than the view. I want to scale the image to the width of the screen and adjust the height of the ImageView to reflect the…

Mundi
- 79,884
- 17
- 117
- 140
86
votes
11 answers
How do I remove extra space above and below imageView?
I have a really simple image within a RelativeLayout and for some reason I am getting extra spacing on the top and bottom which I can't remove. How can I clear it out?
Here is what it looks like:
Here is the code:

UKDataGeek
- 6,338
- 9
- 46
- 63
80
votes
5 answers
How do you setLayoutParams() for an ImageView?
I want to set the LayoutParams for an ImageView but cant seem to find out the proper way to do it.
I can only find documentation in the API for the various ViewGroups, but not an ImageView. Yet the ImageView seems to have this functionality.
This…

DeadTime
- 841
- 1
- 6
- 6
79
votes
5 answers
Maximum width and height for ImageView in Android
So I have an ImageView set with
android:maxHeight="100px"
android:maxWidth="250px"
android:minHeight="100px"
android:minWidth="250px"
android:scaleType="centerInside"
This image view is used to show a picture that is obtained from the gallery or…

Miguel Ribeiro
- 8,057
- 20
- 51
- 74
76
votes
3 answers
Image View not Wrapping Contents
I've got an ImageView wrapping this image:
and right below it, a TextView.…

Tyler Sebastian
- 9,067
- 6
- 39
- 62
76
votes
10 answers
ImageView be a square with dynamic width?
I have a GridView with ImageViews inside. I have 3 of them for each row. I can set correctly the width with WRAP_CONTENT and scaleType = CENTER_CROP, but I don't know how to set the ImageView's size to be a square. Here's what I did until now, it…

Andrea
- 4,262
- 4
- 37
- 56
75
votes
4 answers
What is the difference between src and background of ImageView
I am a puzzled about using src or background for an ImageView.
I know the former means the content of this ImageView and the latter means the background of the ImageView.
But how to decide which one to use? I don't see the difference.

peter_feng
- 855
- 2
- 7
- 11
74
votes
4 answers
Android ImageView size not scaling with source image
I have a few ImageViews inside a LinearLayout. I need to scale down the ImageViews so that they maintain their aspect ratios whilst fitting inside the LinearLayout vertically. Horizontally, I just need them to be adjacent to each other.
I've made…

Rok
- 2,568
- 4
- 26
- 28
74
votes
14 answers
Show GIF file with Glide (image loading and caching library)
I try to show a GIF image as loading placeholder in image view - with Glide Library:
Glide.with(context)
.load(ImageUrl())
.placeholder(R.drawable.loading2)
.asGif()
.crossFade()
.into(image);
I try to show this file…

mahdi
- 16,257
- 15
- 52
- 73
74
votes
13 answers
Make ImageView fit width of CardView
I have a CardView with rounded corners, I want to have an ImageView at the top like shown in the example taken from the material design guidelines below.

Dan
- 3,879
- 5
- 36
- 50
72
votes
4 answers
How to auto center crop ImageView Android?
I made a listView images. My goal that each item of my listView have the same height of 100dp. I encounter a problem that my imageView is resized automatically, but does not take the entire space of the parent.
Here is my current result and objectif…

lopez.mikhael
- 9,943
- 19
- 67
- 110