android - 垂直滑动布局内的水平滚动
问题描述
我有一个类似于导航抽屉的自定义视图类,但它是从下到上打开的。
在我的 XML 中,我有一个由这个自定义类包装的水平回收视图。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/video_cutter_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/videoview_bg"
android:orientation="vertical"
tools:ignore="RtlHardcoded">
<RelativeLayout
android:id="@+id/layout_surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/layout"
android:background="@android:color/transparent"
android:gravity="center"
android:orientation="vertical">
<com.devbrackets.android.exomedia.ui.widget.VideoView
android:id="@+id/video_loader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<ImageView
android:id="@+id/icon_video_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/play_button"
android:contentDescription="@null" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="72dp"
android:background="?attr/video_timeline_bg">
<RelativeLayout
android:id="@+id/timeText"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textTimeStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginStart="7dp"
android:layout_marginLeft="7dp"
android:gravity="left"
android:text="@string/timer2" />
<TextView
android:id="@+id/textTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center"
android:text="@string/timer2"
android:textColor="?attr/color_accent" />
<TextView
android:id="@+id/textTimeEnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginEnd="7dp"
android:layout_marginRight="7dp"
android:layout_toEndOf="@+id/textTime"
android:layout_toRightOf="@+id/textTime"
android:gravity="right"
android:text="@string/timer2" />
</RelativeLayout>
<androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/handlerTop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:max="1000"
android:paddingTop="30dp"
android:progressDrawable="@android:color/transparent"
android:secondaryProgress="0"
android:thumb="@drawable/vector_apptheme_text_select_handle_middle" />
<View
android:id="@+id/lineTop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/handlerTop"
android:background="@color/line_button" />
</RelativeLayout>
<SlidingLayer xmlns:slidingLayer="http://schemas.android.com/apk/res-auto"
android:id="@+id/slider_panel"
android:layout_width="match_parent"
android:layout_height="400dip"
android:layout_below="@+id/layout_surface_view"
android:layout_gravity="bottom"
android:gravity="bottom"
slidingLayer:openLayer="false"
slidingLayer:stickTo="bottom">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="400dip"
android:background="@color/slider_panel_color_trans98">
<TextView
android:id="@+id/added_clips_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="7dp"
android:padding="7dp"
android:text="Selected 0 clips"
android:textColor="?attr/text_color"
android:textSize="@dimen/sp12"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/slider_iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="top|center"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@null"
android:padding="7dp"
android:tint="?attr/color_accent"
app:srcCompat="@drawable/vector_slide_down" />
<Button
android:id="@+id/btAdd"
style="@style/BorderlessButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="center"
android:shadowColor="?attr/textview_shadow"
android:shadowDx="@integer/shadowDx"
android:shadowDy="@integer/shadowDy"
android:shadowRadius="@integer/shadowRadius"
android:text="@string/add"
android:textColor="?attr/color_accent"
android:textSize="@dimen/sp14"
android:textStyle="bold" />
<Button
android:id="@+id/btNext"
style="@style/BorderlessButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/btAdd"
android:gravity="center"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:shadowColor="?attr/textview_shadow"
android:shadowDx="@integer/shadowDx"
android:shadowDy="@integer/shadowDy"
android:shadowRadius="@integer/shadowRadius"
android:text="@string/next"
android:textColor="?attr/color_accent"
android:textSize="@dimen/sp14"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/mRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btAdd"
android:background="@color/slider_panel_color_trans98"
android:scrollbarSize="@dimen/scrollbar_size"
android:scrollbarStyle="outsideInset"
android:scrollbarThumbHorizontal="?attr/color_accent"
android:scrollbars="horizontal" />
</RelativeLayout>
</SlidingLayer>
</RelativeLayout>
所以我在垂直幻灯片(自定义视图)内有一个水平滚动(recyclerview )。
问题是这样的,请看下面的GIF文件:
如您所见,我无法在 recyclerview 中正确滚动。
你有什么建议吗?
解决方案
在SlidingLayer.java类内部onInterceptTouchEvent
方法中添加以下代码以进行MotionEvent.ACTION_MOVE
操作:
if (xDiff > yDiff) {
return false;
}
它看起来像:
switch (action) {
case MotionEvent.ACTION_MOVE:
.
.
.
if (xDiff > yDiff) {
return false;
}
if (validHorizontalDrag || validVerticalDrag) {
mIsDragging = true;
setDrawingCacheEnabled(true);
}
break;
.
.
.
推荐阅读
- javascript - 用 Promise 同步 javascript 函数,socket.io 发射
- c - 关于如何添加保存在两个结构中的两个数字并将它们保存在第三个结构中的任何想法
- objective-c - 在 Objective-C 中,在执行密集操作的循环中,使用 @synchonized 是否有利于实现的稳定性?
- php - 如何使用 PHP 中的 prepare 方法将数据从一个表移动到另一个表
- javascript - 输入不更新
- multithreading - 是否可以在 Akka Actor 的 Actor 函数中定义线程?
- python - 为熊猫数据框中缺少的时间戳填充零
- c# - TreeView 项目随机出现在错误的父项下
- python - 为什么我的记忆在流血?
- probability - 他们将与其中至少一个正确的情况相矛盾的案例百分比