开发者

How can I create horizontal view scrolling like the News & Weather app?

Android News & Weather app lets you swipe to reveal another view, just like the iPhone. Can someone show me an example of how this is done?

It is not a ViewFlipper attached to a Ge开发者_JAVA百科stureDetector.


It is a custom view, you can see how it's done in Launcher by looking at Workspace.java in packages/apps/Launcher2 at android.git.kernel.org.


You can now do this out-of-the-box in the Android Compatibility library with a ViewPager: http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html?m=1

ViewPager slides between Fragments much the same way ListViews scroll up and down with views.

If you're not interested in scrolling the tabs, there's an example in the SDK that uses a TabHost (instead of making the tabs themselves scrollable left-to-right), but you need not use a TabHost. You could, if you wanted horizontally-scrolling tabs, use a HorizontalScrollView with some buttons in it.

For an approach that doesn't use the compatibility lib, or fragments, see here: https://github.com/olibye/AndroViews

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜