简体   繁体   English

如何使用片段和视图分页器在android中的选项卡宿主指示器上实现滑动效果

[英]How to implement sliding effect on the tab host indicator in android using fragment and view pager

I am new to android development and I want to implement a sliding effect on the tab host when the user slides left or right to change tabs implemented using fragments and view pager. 我是android开发的新手,我想在用户向左或向右滑动以更改使用片段和查看分页器实现的选项卡时在选项卡主机上实现滑动效果。

As soon as the user slides the page, the tab host indicator should also slide. 用户滑动页面后,选项卡宿主指示器也应滑动。

Facebook's new android app has this already implemented. Facebook的新android应用已经实现了这一点。 Please refer to this image for a better understanding as to what I mean. 请参考此图片以更好地理解我的意思。

Sample Image 样本图片

在此处输入图片说明

Thanks for any help available :) 感谢您提供的任何帮助:)

It's possible to use ActionBar tabs, but this design mode has been deprecated in API 21 , and it works differently on different sized screens anyway which can lead to some undesired effects. 可以使用ActionBar选项卡,但是API 21中已弃用了此设计模式,无论如何,它在不同大小的屏幕上的工作方式都不同,这可能会导致某些不良效果。

I used the classes in SlidingTabs example from Android developers to achieve this effect without having to include a 3rd party library dependency. 我使用了来自Android开发人员的SlidingTabs示例中的类来实现此效果,而不必包含第三方库依赖项。 There is a video tutorial as well. 还有一个视频教程

Use a ViewPager with ActionBar tabs. 将ViewPager与ActionBar选项卡一起使用。

See here, http://developer.android.com/training/implementing-navigation/lateral.html 参见此处http://developer.android.com/training/implementing-navigation/lateral.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM