Hansjörg Hofer
Hansjörg Hofer

Reputation: 539

Android widget size and ImageView from XML

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.

Upvotes: 0

Views: 775

Answers (1)

Hansj&#246;rg Hofer
Hansj&#246;rg Hofer

Reputation: 539

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

Upvotes: 2

Related Questions