I have a layout problem with ImageView. I'm trying to display an image, with a border drawn round it, at the largest possible size that will fit in an area without changing the aspect ratio. I'm doing this with a simple ImageView, with the border drawn using a Drawable attached to android:background.
According to the specs, setting android:adjustViewBounds="true" is supposed to cause the ImageView to resize itself to match the size of the image it's displaying (after scaling). However, I'm finding that this doesn't seem to make any difference. I finding that I either have the ImageView expanding to fill all the available area (which means the border's not drawn in the right place), or shrinking down to the image's natural size (which means it's floating in the middle of lots of empty space), regardless of whether it's set or not. Which one I get depends on whether the ImageView's size is fill_parent or wrap_content. My XML looks like: <LinearLayout ...> ... <ImageView android:id="@+id/bigcover" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" android:adjustViewBounds="true" android:scaleType="fitCenter" android:background="@drawable/imageframe" android:src="@drawable/actuallythisissetprogrammatically" /> ... /> I would have *thought* that what I want to make this work is (a) set the size to fill_parent (to make the maximum size available to the ImageView) and then set adjustViewBounds (to cause the ImageView to resize itself to match the image). The LinearLayout will then float the ImageView in the middle of the cell. Unfortunately this doesn't work. Any suggestions? Am I going to have to resort to code? -- ┌─── dg@cowlark.com ───── http://www.cowlark.com ───── │ │ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)' │ --- Conway's Game Of Life, in one line of APL
signature.asc
Description: OpenPGP digital signature