0

I have the following widget :

Widget diff Size

The Image is ok if the widget size w=h , but its streching if different.

How to keep it proportional ? And resize should even work.

My XML :

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Widget"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >

<ImageView
    android:id="@+id/buttonwidget"
    android:src="@drawable/normalwidget"
    android:layout_gravity="center"
    android:adjustViewBounds="true"
    android:fitsSystemWindows="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY" >
</ImageView>

I would prefer a XML solution and not Drawable code if possible.

Hansjörg Hofer
  • 409
  • 1
  • 5
  • 18
  • 1
    Check this thread [How to scale an Image in ImageView to keep the aspect ratio][1]. It should answer your question. :) [1]: http://stackoverflow.com/questions/2521959/how-to-scale-an-image-in-imageview-to-keep-the-aspect-ratio – Samuil Yanovski Sep 08 '13 at 12:51
  • Thanks alot android:scaleType="fitCenter" is working nice :) – Hansjörg Hofer Sep 08 '13 at 13:21

1 Answers1

2

Thanks to @Samuil Yanovski he did fix it..

i changed my XML to :

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Widget"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >

<ImageView
    android:id="@+id/buttonwidget"
    android:src="@drawable/normalwidget"
    android:layout_gravity="center"
    android:adjustViewBounds="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitCenter">
</ImageView>

</FrameLayout>

And all is fine how i like it :)

All fixed

Hansjörg Hofer
  • 409
  • 1
  • 5
  • 18