Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android RecycleView单元中的垂直显示效果,如折叠视图_Android_Android Recyclerview - Fatal编程技术网

Android RecycleView单元中的垂直显示效果,如折叠视图

Android RecycleView单元中的垂直显示效果,如折叠视图,android,android-recyclerview,Android,Android Recyclerview,我正试图找到一个解决方案来回收视图,如下所示: 我尝试了很多方法,但仍然没有成功,也许有人可以给我一个提示或建议库?我几乎解决了在onScroll中设置填充的问题,但实际上不知道为什么内容偏移量与getTop()不同 我几乎解决了在onScroll中设置填充的问题,但实际上不知道为什么内容偏移量不同于getTop() 我的单元格布局可能有问题 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:a

我正试图找到一个解决方案来回收视图,如下所示:


我尝试了很多方法,但仍然没有成功,也许有人可以给我一个提示或建议库?

我几乎解决了在onScroll中设置填充的问题,但实际上不知道为什么内容偏移量与getTop()不同


我几乎解决了在onScroll中设置填充的问题,但实际上不知道为什么内容偏移量不同于getTop()


我的单元格布局可能有问题

  <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:clipChildren="true">

        <ImageView
            android:id="@+id/image_foxy"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/fox700"
            />

  </RelativeLayout>

我的单元格布局可能有问题

  <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:clipChildren="true">

        <ImageView
            android:id="@+id/image_foxy"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/fox700"
            />

  </RelativeLayout>

好的,我无法解释为什么,但我的解决方案是将内容填充设置为距离桌面可见距离的两倍:

 @Override
 public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
  int contentPaddingTop =  -childView.getTop() * 2; 
  childView.setPadding(0,contentPaddingTop,0,0);
}

好的,我无法解释为什么,但我的解决方案是将内容填充设置为与桌面可见距离相等的两倍:

 @Override
 public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
  int contentPaddingTop =  -childView.getTop() * 2; 
  childView.setPadding(0,contentPaddingTop,0,0);
}

那么到目前为止你尝试了什么呢。我试着加入一个听众,改变牢房里的视角高度——很难做到流畅的表演。2.现在我正在尝试实现这个库,但它在recycleview单元中的行为并不像预期的那样,所以到目前为止您尝试了什么?1。我试着加入一个听众,改变牢房里的视角高度——很难做到流畅的表演。2.现在我正在尝试实现这个库,但它在recycleview单元中的行为并不像预期的那样,购买
内容偏移量
是什么意思?你还需要做什么?观看视频:我需要目标单元格中的视图被卡住,在滚动列表时不移动,但它仍在移动。我的意思是当单元格第一次出现时,你必须看到视图的最底部(padding=view.height),但它是从视图的中间开始出现的。当完全在屏幕上查看时,它工作正常(padding=0)。购买内容偏移量是什么意思?你还需要做什么?观看视频:我需要目标单元格中的视图被卡住,在滚动列表时不移动,但它仍在移动。我的意思是当单元格第一次出现时,你必须看到视图的最底部(padding=view.height),但它是从视图的中间开始出现的。当完全在屏幕上查看时,它工作正常(padding=0)。