Search code examples
androidandroid-jetpack-composeglance

Glance for Android AppWidgets: ViewFlipper Equivalent


https://developer.android.com/jetpack/compose/glance/build-ui

I'm looking at Glance UI for Widgets as an alternative to the old way - using remoteviews.

RemoteViews allowed the use of AdapterViewFlipper.

<AdapterViewFlipper
    android:id="@+id/content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerHorizontal="true"
    android:animateFirstView="false"
    android:autoStart="true"
    android:flipInterval="@integer/marquee_flip_interval"
    android:inAnimation="@animator/fade_in"
    android:outAnimation="@animator/fade_out"
    android:loopViews="true" />

Something like this was good for an image Marquee - a gallery of images that rotate every ten seconds or so.

Is there some way to do it in glance? Sure it can be a LazyRow that fits one item at a time, but I'd have to advance the list somehow.

Note, I'm not asking about whether I can do this with next and previous buttons or other user interactions. I'm asking whether I can make the images autorotate.


Solution

  • Glance doesn't have a component for it. However, it provides a AndroidRemoteViews component for such situations.

    The Glance's demos directory in Androidx source code has an example that demonstrates using a view flipper.