limbowangqi / FloatWindow

29 stars 5 forks source link

自定义 View 里面使用了 Rv 的情况下,悬浮窗无法拖动 #3

Open Goooler opened 1 year ago

Goooler commented 1 year ago

Layout:

<LinearLayout
    android:layout_width="200dp"
    android:layout_height="300dp"
    android:background="@color/common_black">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv_list"
        android:layout_width="200dp"
        android:layout_height="300dp"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        tools:listitem="@layout/main_common_rv_item" />

</LinearLayout>
Goooler commented 1 year ago

自己处理的话就是根布局拦截事件:

class FloatingRootLayout @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
    FrameLayout(context, attrs) {

    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean = true
}
Goooler commented 1 year ago

解决了滑动冲突之后拖动悬浮窗,更新 Rv 的数据,会有两个悬浮窗同时出现

limbowangqi commented 1 year ago

这个场景,我这周试下;