0

I got this ImageView:

<ImageView
     android:id="@+id/myImage"
     android:sec="@drawable/my_selector"
     android:layout_height="match_parent"
     android:layout_width="wrap_content"
     android:layout_alignParentLeft="true"
     android:scaleType="fitCenter"
     android:adjustViewBounds="true" />

The problem is that I keep getting spaces in the sides of the image INSIDE the ImageView. If I change the scale type to fitStart, the image simply moves to the left with a very large space on its right (the sum of the 2 spaces from the sides that were with fitCenter).

How can this space be removed?

JJ Ab
  • 492
  • 4
  • 15
  • Show your snapshot ! – Piyush Aug 31 '16 at 07:52
  • @Piyush I can't since my computer Im developing on is not connected to the internet. I had to copy the imageView's declaration by hand. but its really not complicated - the image view simply doesn't wrap its content and is created larger than the image instead of being at the same size as the image. – JJ Ab Aug 31 '16 at 07:55
  • Ok.! Show full xml file – Piyush Aug 31 '16 at 07:57
  • If any of the answer solved your problem please mark it accepted or tell me if you need more help! – bendaf Aug 31 '16 at 10:43
  • Can't mark mine yet for another 2 days – JJ Ab Aug 31 '16 at 10:48

4 Answers4

0

I suppose your ImageView is quite large for the size of your image.

You have to use one of the center tags. Centerinside possibly.

Stefan
  • 2,098
  • 2
  • 18
  • 29
0

You can maintain aspect ratio for imageview for that see this answer given by MH.

Community
  • 1
  • 1
KDeogharkar
  • 10,939
  • 7
  • 51
  • 95
  • That answer addresses another issue where you want to increase the imageview and the image along with it. My imageview simply doesn't wrap its content correctly and I don't want to increase my image. – JJ Ab Aug 31 '16 at 07:53
0

It seems like the problem is with Eclipse's Graphical Layout itself. It seems like the problem was simply the image being very large and the graphical layout window did not display the image correctly like the actual view in the device, there I saw a very large image that fits the image view. When reducing the image's size, it worked out.

JJ Ab
  • 492
  • 4
  • 15
0

Try change scaleType to fitXY , matrix or center like:

<ImageView
     android:id="@+id/myImage"
     android:sec="@drawable/my_selector"
     android:layout_height="match_parent"
     android:layout_width="wrap_content"
     android:layout_alignParentLeft="true"
     android:scaleType="fitXY"
     android:adjustViewBounds="true" />

check this page for more info.

bendaf
  • 2,981
  • 5
  • 27
  • 62