s.d
s.d

Reputation: 29436

App Widget always wrapping layout around content

I've tried layout_width attribute to match_parent as well as fill_parent on the root element of layout file, for a home screen widget. But when shown in App Widget, it's still being wrapped around the content.

App widget layout:

<StackView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/xxxxxxxxx"
    android:layout_width="match_parent" <!-- always acts like wrap_content -->
    android:layout_height="fill_parent"
    android:gravity="center"
    android:loopViews="true" />

Widget is assigned grid size of 4X2:

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="250dp"
    android:minHeight="110dp"
    . . . . .  />

But still after being added to a home screen, the widget's width doesn't take up 4 grids on home screen, it just wraps around the content. How can this be solved ?

Upvotes: 0

Views: 482

Answers (1)

AutoM8R
AutoM8R

Reputation: 3080

Having a similar problem, it appears minHeight and minWidth factor into the max size as well, I bet if you increased the minWidth to (4 * 74) - 2 = 294dp it'd work. For your minHeight, the pixel height per the guide would be (2 * 74) - 2 = 146dp, just so you know.

Upvotes: 1

Related Questions