开发者

A page flipper control - like the android home screens

Anyone know of a library or method I can use to emulate the way the Android homescreens work?

What I mean is this:

A control that will take any number of sub-Views. It will only show one of those Views at a time, however, when the user drags their finger over the screen, it'll switch to the next or previous view, depending on which way the user dragged their finger.

I'v开发者_StackOverflow中文版e seen a few examples (SwipeGestureListener comes to mind), but they don't work in the way I'd like. They require a swipe gesture, which means the widget doesn't move unless there is an actual swipe. For this reason, it's not readily obvious that the pages are switchable using this method.

Any information would be great.


This is probably what you need http://code.google.com/p/deezapps-widgets/.

Tried to use it in a project of mine but didn't work well with ListViews with a gradient as the background.


Homescreen

This link is the android source code. Workspace.java is what u will need. The workspace.java extends the ViewGroup and u can strip down the code to your needs..


The control you mentioned above is called ViewPager - it's from Android Compatibility Package of Android. But the default Android ViewPager doesn't include a "pager indicator" control.

Don't worried. There are many open source library give you a "pager indicator" control along with ViewPager. IMHO, two of the best are:

  • android-viewflow: https://github.com/pakerfeldt/android-viewflow

  • Android-ViewPagerIndicator: https://github.com/JakeWharton/Android-ViewPagerIndicator

If you have time, it's good to check out many Android UI controls which included in "Android UI Patterns" app: https://market.android.com/details?id=com.groidify.uipatterns


Check out ViewFlipper, ViewSwitcher etc. depending on your need.

http://developer.android.com/reference/android/widget/ViewFlipper.html

There are some neat samples included in the SDK.

For swipes and other gestures capture MotionEvents and act accordingly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜