XxGoliathusxX XxGoliathusxX - 1 month ago 19
Android Question

Android Widget Stretch/Shrink

I created a little widget for my application. It's 4 cells wide and 1 cell high.
As you can see on the picture, my device has a width of 5 cells. So I would like to support 5x1 too. Same layout, content stretched. How do I do this?

My thougths:

- Do I have to create another widget in size 5x1?

- How to add the functionality to stretch/shrink your widget on the homescreen?

enter image description here

Answer

In your appwidget-provider, set the resize mode:

<appwidget-provider 
    xmlns:android="http://schemas.android.com/apk/res/android"
    ....
    android:resizeMode="horizontal"/>