My suggestion is draw to size, manually, outside of the app.

Basically, the XML will only rarely do what you want, and it will
require some arcane parameter twiddling to even get close to what you
want.  The stretching/shrinking done by the OS is sketchy at best in
my experience.  I have personally never had size declaration work
either, but I was also using image buttons.

On Nov 8, 2:24 pm, David Given <[EMAIL PROTECTED]> wrote:
> 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
> < 1KViewDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to