Friday, November 5, 2010

[android-developers] NinePatch Background around ImageView

Ok I believe it shouldn't be so hard to get this thing done.

What I want to do:
An image view with a border (possibly from a ninepatch). That
ImageView must be of this size 70x70dip. Bitmap and drawable will be
bigger than this dimension. The drawable must scale down and crop to
fit in the ImageView.

What I did:
I partially done it but for some mysterious reasons...It doesn't work
very well. I can post my layout but I don't believe it's necessary. I
just don't understand the logic behind the ImageView and scaling.

I used centerCrop to crop scale my Bitmap in the image view while
keeping aspect ratio. It worked fine...until I added a background...I
used a NinePatch and then the scaleType seems to loose its effect. In
other word, if I set a background scaleType switch to centerInside. I
succeded at getting my layout to work...after some time.

I used an NinePatch ressource in my xml layout and when I
programmatically change the background for a different ressource. It
mess the layout. Instead of having a 2dip padding all around my
ImageView. I get something like 2dip padding top/left and 5dip right/
bottom... But I'm using the same NinePatch I used in the layout. So
since it's the same NinePatch I believe the background/layout around
my ImageView shouldn't change in size,padding,margin,scaling or
whatever...

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate