OnTouchEvent not working on child views

前端 未结 7 1906
梦如初夏
梦如初夏 2020-11-29 21:45

I have a Linear Layout that has a Button and a TextView on it. I have written a OnTouchEvent for the activity. The code works fine if I touch on the screen, but if I touch t

7条回答
  •  一生所求
    2020-11-29 22:20

    RecyclerView list_view = findViewById(R.id.list_view);
    list_view.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener(){
        @Override
        public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
            View child = rv.findChildViewUnder(e.getX(), e.getY());
            Log.i("Hello", "World");
            return false;
        }
    });
    

提交回复
热议问题