Android 드래그 앤 드롭 프레임워크를 사용하면 앱에 대화형 드래그 앤 드롭 기능을 추가할 수 있습니다. 사용자는 드래그 앤 드롭을 사용하여 텍스트, 이미지, 객체, URI로 표현될 수 있는 모든 콘텐츠를 앱 내의 한 View에서 다른 View로 또는 멀티 윈도우 모드에서 앱 간에 복사하거나 이동할 수 있습니다.
그림 1. 앱 내에서 드래그 앤 드롭
그림 2. 앱 간의 드래그 앤 드롭
프레임워크에는 드래그 이벤트 클래스, 드래그 리스너, 도우미 클래스 및 메서드가 포함되어 있습니다. 이 프레임워크는 주로 데이터 전송을 지원하도록 설계되었지만 다른 UI 작업에도 사용할 수 있습니다. 예를 들어 사용자가 색상 아이콘을 다른 아이콘 위로 드래그하면 색상을 혼합하는 앱을 만들 수 있습니다. 그러나 나머지 문서에서는 데이터 전송의 컨텍스트에서 드래그 앤 드롭 프레임워크를 설명합니다.
드래그 이벤트: 사용자가 앱의 레이아웃 위로 드래그 섀도우를 이동하면 시스템에서 레이아웃의 View 객체와 연결된 드래그 이벤트 리스너 및 콜백 메서드로 드래그 이벤트를 전송합니다.
드래그 앤 드롭 작업은 사용자가 앱에서 데이터 드래그를 시작하는 신호로 인식하는 UI 동작을 할 때 시작됩니다. 이에 응답하여 앱은 시스템에 드래그 앤 드롭 작업이 시작되었음을 알립니다. 시스템에서 앱을 다시 호출하여 드래그 그림자를 표시하고 드래그 앤 드롭 프로세스 중에 사용자에게 표시합니다.
사용자가 앱의 레이아웃 위로 드래그 섀도우를 이동하면 시스템에서 레이아웃의 View 객체와 연결된 드래그 이벤트 리스너 및 콜백 메서드로 드래그 이벤트를 전송합니다. 사용자가 드롭 타겟 위에 드래그 섀도우를 놓으면 시스템은 여기에 데이터를 전송합니다. 드래그 앤 드롭 작업은 드래그 섀도우가 드롭 타겟 위에 있는지와 상관없이 사용자가 드래그 섀도우를 놓으면 종료됩니다.
드래그 앤 드롭 샘플: 리치 미디어 허용과 더불어 드래그 앤 드롭을 구현하는 다양한 방법이 포함되어 있습니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-26(UTC)"],[],[],null,["# Enable drag and drop\n\nTry the Compose way \nJetpack Compose is the recommended UI toolkit for Android. Learn how to use drag and drop in Compose. \n[Drag and drop →](/develop/ui/compose/touch-input/user-interactions/drag-and-drop) \n\n\u003cbr /\u003e\n\n| **Note:** See the improved method of implementing drag and drop in [Receive rich\n| content](/develop/ui/views/receive-rich-content) for a better UX and improved maintainability of your code.\n\nThe Android drag-and-drop framework lets you add interactive drag-and-drop\ncapabilities to your app. With drag and drop, users can copy or move text,\nimages, objects, and any content that can be represented by a URI, from one\n[`View`](/reference/android/view/View) to another within an app, or between apps\nin [multi-window mode](/develop/ui/views/touch-and-input/drag-drop/multi-window#DragPermissionsMultiWindow).\n\n|--------------------------------------------|-------------------------------------------|\n| | |\n| **Figure 1.** Drag and drop within an app. | **Figure 2.** Drag and drop between apps. |\n\nThe framework includes a drag event class, drag listeners, and helper classes\nand methods. Although primarily designed to enable the transfer of data, you can\nuse the framework for other UI actions. For example, you can create an app that\nmixes colors when the user drags a color icon over another icon. However, the\nrest of document describes the drag-and-drop framework in the context of data\ntransfer.\n\nOverview\n--------\n\nThere are a few elements involved in the drag process.\n\n1. Drag source: The start point view of drag-and-drop process.\n\n2. Drop target: A view that can accept the drag data.\n\n3. [Drag shadow](/develop/ui/views/touch-and-input/drag-drop/concepts#AboutDragShadowBuilder):\n A *drag shadow* is a representation\n of the data being dragged, it's visible to users.\n\n4. [Drag events](/develop/ui/views/touch-and-input/drag-drop/concepts#AboutDragEvent):\n As the user moves the drag shadow over the\n app's layout, the system sends drag events to the drag event listeners and\n callback methods associated with the `View` objects in the layout.\n\nA drag-and-drop operation starts when the user makes a UI gesture that your app\nrecognizes as a signal to start dragging data. In\nresponse, the app notifies the system that a drag-and-drop operation is\nstarting. The system calls back to your\napp to get a *drag shadow*. and show it to users during drag-and-drop process.\n\nAs the user moves the drag shadow over the app's layout, the system sends drag\nevents to the [drag event listeners and callback methods](/develop/ui/views/touch-and-input/drag-drop/concepts#AboutDragListeners)\nassociated with the `View` objects in the layout. If the user releases the drag\nshadow over a drop target, the system sends the data to it. The drag-and-drop\noperation ends when the user releases the drag shadow, whether or not the drag\nshadow is over a drop target.\n\nTopics\n------\n\n[Key Concepts](/develop/ui/views/touch-and-input/drag-drop/concepts)\n: Understand the drag-and-drop process.\n\n[DropHelper for simplified drag and drop](/develop/ui/views/touch-and-input/drag-drop/drophelper)\n: Learn how to implement drag and drop with `DropHelper`.\n\n[Implement drag and drop with views](/develop/ui/views/touch-and-input/drag-drop/view)\n: Alternatively, implement drag and drop with Android views, this allows\n developers to have more control of the details.\n\n[Drag and drop in multi-window mode](/develop/ui/views/touch-and-input/drag-drop/multi-window)\n: Support drag and drop in multi-window mode, allow objects to move across\n different applications.\n\nAdditional resources\n--------------------\n\n- [Codelab for Drag and Drop](/codelabs/codelab-dnd-views) using views\n- [Drag \\& drop for seamless multitasking](https://www.youtube.com/watch?v=WOm76wSfkbU) video\n- [Drag and Drop Samples](https://github.com/android/platform-samples/tree/main/samples/user-interface/draganddrop) which contains various ways to implement drag and drop along with accepting rich media."]]