0

What I am trying to do is change the width of the image in a ImageView without affecting the width of ImageView.

    ----------------------------------------------------------------
    |                                                              |
    |                                                              |
    |         ----------------------------------------------       |
    |         |                                            |       |
    |         |                                            |       |
    |         |    this is the image( change its width)    |       |
    |         |                                            |       |
    |         ----------------------------------------------       |
    |                                                              |
    |      this is imageView the width mustnt change               |
    ----------------------------------------------------------------

How can I achieve this ? Please Help?

Navdroid
  • 1,541
  • 3
  • 25
  • 52

2 Answers2

5

You can use ScaleType for that. Like,

imgV.setScaleType(ImageView.ScaleType.CENTER_CROP);

and you can specify Padding property too.

see the link it might help you.

Android ImageView adjusting parent's height and fitting width

Community
  • 1
  • 1
Zombie
  • 1,965
  • 2
  • 20
  • 34
0

ImageView and image are not different. To show an image in an Android device we are using an ImageView. If you want to show an image at the centre of something, then wrap the image view with some layout and set the image inside that layout with some padding all the side you need.

Chandra Sekhar
  • 18,914
  • 16
  • 84
  • 125