向外推/拉的动作条在ListView中滚动 [英] Push out/pull in ActionBar when ListView is scrolled

查看:115
本文介绍了向外推/拉的动作条在ListView中滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌最新的报亭应用,设有一个动作条 ViewPager 标签栏慢慢地简化了屏幕的上方当它下面的列表向下滚动。 重要的是,它简化了以相同的速度列表滚动。当列表向上滚动的动作条减轻背部到屏幕上,再次以相同的速度列表滚动

The latest Google Newsstand App features an ActionBar and ViewPager tab bar which slowly eases out the top of the screen when the list below it is scrolled down. Importantly, it eases out at the same speed the list is scrolled. When the list is scrolled upwards the ActionBar eases back onto the screen, again at the same speed the list is scrolled.

我不是指动作条 隐藏()节目()方法,而不是我想知道如何隐藏和显示的动作条以同样的速度在它下面的列表中滚动。

I am not referring to the ActionBar hide() and show() methods, instead I want to know how to hide and show the ActionBar at the same rate the list below it is scrolled.

这是如何实现的?所有试图在寻找文件的解决方案已被证明不成功的,因此任何帮助将是AP preciated。

How is this achieved? All attempts at finding a documented solution have proven unsuccessful so any help would be appreciated.

推荐答案

创建片段子类,它充当一个动作条代替。请使用OnScrollListener更新片段的视图的 translationY 滚动事件后。

Short Answer

Create a Fragment subclass that serves as an ActionBar replacement. Use an OnScrollListener to update the fragment's view's translationY after scroll events.

周围挖的动作条源$ C ​​$ C后,似乎没有公共的方法来访问的ActionBar容器视图。但是,在有遗嘱,有一种方法

After digging around the ActionBar source code, it seems that there is no public method for accessing the ActionBar container view. But where there's a will, there's a way.

您可以使用下面的抢参考操作栏的看法:

You can grab a reference to the Action Bar's view using the following:

int resId = getResources().getIdentifier("action_bar_container", "id", "android");
View actionBarContainer = findViewById(resId);

免责声明 action_bar_container 是一个私人的ID,所以它是受到谷歌的念头。使用您自己的风险。

Disclaimer: action_bar_container is a private ID, so it's subject to Google's whims. Use at your own risk.

一旦你的操作栏的看法,你可以激活它,但是你会喜欢的。

Once you have the Action Bar's view, you can animate it however you'd like.

我砍死在一起一个半功能例如的,如果你有兴趣。

I hacked together a semi-functional example if you're interested.

希望这有助于!

这篇关于向外推/拉的动作条在ListView中滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆