How to handle tocuh event for paret and child views in Android

I am trying to implement drag-and-drop functionality in my app using the DragLinearLayout class. I have successfully implemented the drag-and-drop feature. Now, I want to enable drag-and-drop when the user long-presses the layout and also add a delete button to each layout when drag-and-drop is enabled.

To achieve this, I read the views when the user long-presses the layout, place each layout inside a FrameLayout, add a close button to the FrameLayout, and then place the FrameLayout inside DragLinearLayout. However, I am facing an issue. I cannot drag the view when I add the FrameLayout. After intercepting the touch events for the FrameLayout, I can perform drag-and-drop, but I cannot click the close button. I have overridden the onTouch event for the close button as well, but it is not working. Please help me resolve this issue.

private void doLongPressProcess() {

        for (int i = 0; i < dragLayout.getChildCount(); i++) {

            View child = dragLayout.getChildAt(i);
            child.setId(View.generateViewId());
            child.setTag("" + i);
            FrameLayout childFrame = getFrameLayout(i);

            dragLayout.removeViewAt(i);
            childFrame.addView(child);
            dragLayout.addView(childFrame, i);

            if (i != 0 && i != 2) {
//To enable drag and drop only for 0 and 2nd position
                dragLayout.setViewDraggable(childFrame, childFrame);
                ImageView closeButton = getImageView(child, dragLayout);
                (childFrame).addView(closeButton);
            } else {
                dragLayout.disableViewDraggable(child, child);
            }
        }

    }

    @NonNull
    private FrameLayout getFrameLayout(int i) {

        FrameLayout childFrame = new FrameLayout(context) {

            @Override
            public boolean onInterceptTouchEvent(MotionEvent ev) {
                return true;
            }
        };
        childFrame.setTag("Frame" + i);
        childFrame.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT,
                WRAP_CONTENT));
        GradientDrawable border = new GradientDrawable();
        border.setStroke(1, Color.BLACK); //black border with full opacity
        childFrame.setBackground(border);
        return childFrame;
    }


    @NonNull
    private ImageView getImageView(View child, dragLayout dragLayout) {
        ImageView closeButton = new androidx.appcompat.widget.AppCompatImageView(context) {

            @Override
            public void setOnTouchListener(OnTouchListener l) {
                super.setOnTouchListener(l);
            }

            @Override
            public boolean onTouchEvent(MotionEvent event) {
                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        // Notify parent that child might handle the click
                        getParent().requestDisallowInterceptTouchEvent(true);
                        break;
                    case MotionEvent.ACTION_UP:
                        // Handle the click event
                        performClick();
                        // Notify parent that child has handled the click
                        break;
                    case MotionEvent.ACTION_CANCEL:
                        // Cancel the click handling
                        break;
                }
                return super.onTouchEvent(event);
            }
        };
        closeButton.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
        closeButton.setImageResource(R.drawable.ic_close);
        closeButton.setTag(child.getTag());
        closeButton.setY(0);
        closeButton.setX(0);
        closeButton.setOnClickListener(v -> {
            int size = dragLayout.getChildCount();
            for (int i = 0; i < size; i++) {

                if (dragLayout.getChildAt(i).getTag().equals(v.getTag())) {
                    dragLayout.removeViewInLayout(dragLayout.getChildAt(i));
                    break;
                }
            }
        });
        return closeButton;
    }

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật