Question

I noticed that when I swipe my finger from left to right across a home screen widget, in simulator on a AVD, Android switch to the left home screen.

I was wondering if its possible to prevent this behavior and allow home screen gadgets to listen and react to finger gestures (like swipe)? Its very critical for my widget UI design.

Was it helpful?

Solution

Starting with API level 11 (Android 3.0.x) you can use "android.widget.RemoteViewsService.RemoteViewsFactory" and and assign a widget to use (from docs):

ListView: A view that shows items in a vertically scrolling list. For an example, see the Gmail app widget.

GridView: A view that shows items in two-dimensional scrolling grid. For an example, see the Bookmarks app widget.

StackView: A stacked card view (kind of like a rolodex), where the user can flick the front card up/down to see the previous/next card, respectively. Examples include the YouTube and Books app widgets.

See http://developer.android.com/guide/topics/appwidgets/index.html section Using App Widgets with Collections.

So yes - if you use one of the above layouts your widget will accept gestures.

OTHER TIPS

Sorry I am posting this reply as a separate answer because it wouldn't fit as a comment. :)

So interaction with widgets is very limited.

The thing is, widgets aren't "mini applications," they are... widgets. They live in the world of, and are dependent upon, the real application containing them.

There is a continual demand for widgets to support more and more complicated interactions, but every time we start down that path it ends up making the interaction with the containing application much more complicated as well, and seems likely to negatively impact overall usability.

For example, if widgets can process swipes, then the user is now very uncertain about how they can swipe between screens because they will get different behavior depending where they swipe. They could even get stuck in a state where it is nearly impossible to swipe between screens because of the widgets covering the touchable area.

So the way I would recommend thinking of widgets is as a window into the key information associated with your app, to jump into more details of that information by tapping on the widget and switching to the app, and possibly some additional buttons to perform key operations.

Also as of 2.0, with the new wallpaper themes, you can make the UI of the activity that the user visits from your widget sit on top of the same wallpaper as home. This makes the switch between it and home feel much more like an interaction inside of home rather than with another application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top