On an ImageView, in XML, you can use android:scaleType="centerCrop" to achieve this effect.
If you hope to do this programmatically, take a look at the source code for the Music app [all stock app source code is available from Google.. search for "Android source code" or something and you'll find it, it's all kept in git repositories. In that source package, in /src/ com/android/music/MusicUtils.java on line 1199 you'll find the method setBackground(View, Bitmap) .. This is some example code of manipulating a drawable programmatically.. Although they are doing more here than simply scaling and cropping--they're also desaturating it. To see this code in Action on an Android device select an album that has album art for it and you'll see it scaled, centered, and desaturated as the background of the ListView. Hope this helps. I'm working through a similar issue now, but trying to scale a background drawable [unfortunately android:scaleType isn't working for me.. But I have confirmed it works great on ImageViews] -Nick On Apr 8, 9:10 pm, aspekt9 <aspe...@gmail.com> wrote: > I'm trying to take any image and scale and crop it into a set > dimension square (100px X 100px). What's the easiest way to do this? I > want to maintain the aspect ratio and it seems that I can't do that > and have it in a square ImageView either. What's the trick? -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.