Thomas
Thomas

Reputation: 105

Widget takes more place than it should

my appwidget is defined with the following widget-provider-info

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:configure="de.firepower.andwol.widget.AndWOLWidgetConfigure"
    android:initialLayout="@layout/widget"
    android:minHeight="72dp"
    android:minWidth="72dp"
    android:previewImage="@drawable/icon"
    android:resizeMode="horizontal|vertical"
    android:updatePeriodMillis="180000" >

</appwidget-provider>

and the following layout...

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="@dimen/widget_margin" android:orientation="vertical" android:background="@drawable/appwidget_dark_bg">
    <ImageButton
        android:id="@+id/widgetbutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:src="@drawable/icon"
        android:scaleType="fitCenter"
        android:contentDescription="@string/cd_wake_host">
    </ImageButton>
    <TextView
        android:id="@+id/widgettext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="@string/placeholder_hostname" android:textSize="8dp"
        android:layout_marginBottom="2dp"/>
</LinearLayout>

I thought it should take 1x1 square but it takes 2x2 squares and I don't know why. I could only get it to take 1x1 if I define minHeight and Width lower than 60dp in Widget-Provider-Info. Does anyone know/see what I'm doing wrong?

Thanks in advance :-)

Upvotes: 1

Views: 605

Answers (1)

Eric Nordvik
Eric Nordvik

Reputation: 14746

Take a look here: http://developer.android.com/guide/practices/ui_guidelines/widget_design.html#anatomy_determining_size

To get a widget with a 1x1 cell size you need to set your size to round 40dp in height and width.

Upvotes: 2

Related Questions