Tuesday, June 22, 2010

[android-developers] Disable scaling of ImageView

Hi all.

Most of the time, Android scaling is nice but I have a case where I
don't wan't any scaling and I can't find how to do this.


I made a simple layout to test :


<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/carre"
android:scaleType="@null"
/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/carre"
android:paddingLeft="100px"
android:paddingTop="100px"
android:scaleType="@null"
/>
</FrameLayout>


@drawable/carre is a 100x100 square.
The result is :
qvga : http://www.baroukh.com/qvga.png
hvga : http://www.baroukh.com/qvga.png
wxvga : http://www.baroukh.com/wxvga.png

So hvga is the only screen correct.

I tried to initialise scaleType to "null" but that's not possible
(btw, setScaleType() throw a NullPointerException if scaleType is
null. Shouldn't it theow an IllegalArgumentException ? :
public void setScaleType(ScaleType scaleType) {
if (scaleType == null) {
throw new NullPointerException();
}
)

Do I have to make my own ImageView ?

Thanks for any help ...

Mike

--
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

No comments:

Post a Comment