0

I have the following AlertDialog with an image inside it:

alt text

As you can see there is a small gap just above and just below the image. I'd like to remove that gap.

My layout xml looks like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/alert_thumb_root"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" >

  <ImageView android:id="@+id/thumb"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content" />
</LinearLayout>
mlevit
  • 2,676
  • 10
  • 42
  • 50
  • It works but like you said it does resize the image. I can't understand why Android just doesn't make it the same size as the image... what's the reason for making it bigger? – mlevit Sep 24 '10 at 21:05

2 Answers2

1

Unless you create the whole dialog by your self, it's really difficult to control those kind of things. However, if you don't mind resizing the image, you could try something like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/alert_thumb_root"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" >

  <ImageView android:id="@+id/thumb"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:scaleType="fitXY"/>
</LinearLayout>
Cristian
  • 198,401
  • 62
  • 356
  • 264
0

The best and easy way to achieve this programmatically is to

setAdjustViewBounds(true);

I am answering this now because I have spent many days on the solution and can't find the answer anywhere.