简体   繁体   English

如何在Android中检测滚动视图方向

[英]How to detect Scroll view Direction in Android

Anyone know how to detect ScrollView direction because I have to show and hide ActionBar on scrolling? 有人知道如何检测ScrollView方向,因为我必须在滚动时显示和隐藏ActionBar? I can easily detect with help of listview but don't know about ScrollView. 我可以借助listview轻松检测到,但不了解ScrollView。

you can extend the scrollView because scrollview doesnt have such listener. 您可以扩展scrollView因为scrollview没有此类侦听器。 just extend the scrolView and call your callback from the overrided onScrollChanged method. 只需扩展scrolView并从覆盖的onScrollChanged方法中调用您的回调即可。

then in your xml file use your CustomScrollView like this: 然后在xml文件中使用CustomScrollView,如下所示:

<my.package.CustomScrollView>xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/my_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />

I think what you meant by scroll was detecting which direction, a swipe has been made . 我认为您所说的滚动指的是检测到哪个方向,已经进行了滑动。 Here is an example 这是一个例子

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

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