【发布时间】:2017-12-27 16:30:45
【问题描述】:
我有这样的事情:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="cntxt">
<LinearLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Title -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:gravity="center"
android:padding="20dp"
android:text="@string/title"
android:textColor="@android:color/white"
android:textSize="17sp" />
<!-- Recycler -->
<CustomRecyclerView
android:id="@+id/main_activity_rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:scrollingCache="false" />
</LinearLayout>
当布局滚动到顶部时,当用户用手指进行类似“滑动刷新”的移动时,我需要在 Y 轴上制作平移动画。换句话说,如果回收器在顶部,我需要跟随整个回收器的手指移动。
我尝试将 onTouch 侦听器附加到回收器,但回收器的内部滚动使情况不清楚。 有什么想法来实现这个动画?
如果我将 onTouchListener 附加到 main_layout 并从 iner textview 进行投掷,则动画会正常播放。但是当我触摸回收器时,什么也没有发生(回收器的内卷轴除外) 提前谢谢你。
【问题讨论】:
标签: java android android-layout animation android-recyclerview