Thursday, September 30, 2010

[android-developers] scaleType="fitXY" works scaleType="centerInside" doesnt

Hi,

If you know or can guess please tell me why:

In the FrameLayout below, scaleType="fitXY" will adjust the image to
fit the screen but scaleType="centerInside" doesn't. I need the
aspect ratio preserved which fitXY doesn't do. Please look at the
>>>>>>>>-----------------> below.


<?xml version="1.0" encoding="utf-8"?>

<ScrollView
android:id="@+id/widget54"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
>

<LinearLayout

android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"

>>>>>>>>-----------------> no effect, image is too large

<FrameLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:src = "@drawable/logo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerInside"></ImageView>
</FrameLayout>

>>>>>>>>------------------> scales but aspect ratio lost

<FrameLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:src = "@drawable/logo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"></ImageView>
</FrameLayout>

<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 1"
/>
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 2"
/>
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 3"
/>
<EditText
android:id="@+id/txt"
android:layout_width="fill_parent"
android:layout_height="300px"
/>

</LinearLayout>
</ScrollView>

Thanks,

Shawn

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