{"id":21130243,"url":"https://github.com/justasm/DragLinearLayout","last_synced_at":"2025-07-09T01:32:51.840Z","repository":{"id":19916053,"uuid":"23181862","full_name":"justasm/DragLinearLayout","owner":"justasm","description":"Android LinearLayout with drag and drop to reorder.","archived":false,"fork":false,"pushed_at":"2016-10-10T13:23:07.000Z","size":1563,"stargazers_count":454,"open_issues_count":18,"forks_count":121,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-11-20T05:32:36.839Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justasm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-21T09:41:02.000Z","updated_at":"2024-10-30T12:51:39.000Z","dependencies_parsed_at":"2022-07-12T15:17:29.396Z","dependency_job_id":null,"html_url":"https://github.com/justasm/DragLinearLayout","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/justasm/DragLinearLayout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justasm%2FDragLinearLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justasm%2FDragLinearLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justasm%2FDragLinearLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justasm%2FDragLinearLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justasm","download_url":"https://codeload.github.com/justasm/DragLinearLayout/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justasm%2FDragLinearLayout/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264375458,"owners_count":23598378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T05:32:28.287Z","updated_at":"2025-07-09T01:32:51.403Z","avatar_url":"https://github.com/justasm.png","language":"Java","funding_links":[],"categories":["Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"DragLinearLayout\n================\n\n![Dragging and swapping children views.](/sample/sample_in_action.gif)\n\nAn Android `LinearLayout` that supports draggable and swappable child `View`s.\n\nWhy?\n----\nWhy bother doing drag \u0026 swap in a `LinearLayout` [when][drag_list_1] [there are][drag_list_2]\n[so many][drag_list_3] [solutions][drag_list_4] for `ListView`?\n\n1. *Simplicity* - no need for `ListAdapter`s. By default, works like a `LinearLayout`.\n2. *Flexibility* - supports heterogeneous, selectively draggable (or not draggable), children.\n3. *Portability* - can be used in any layout, e.g. as a child in a `ScrollView` container.\n\nUsage\n-----\nAdd it to your project using Gradle:\n\n```groovy\ncompile 'com.jmedeisis:draglinearlayout:1.1.0'\n```\n\nThe `DragLinearLayout` can be used in place of any `LinearLayout`. However, by default, children\nwill not be draggable. To set an existing `View` as draggable, use\n`DragLinearLayout#setViewDraggable(View, View)`, passing in the child `View` and a (non-null!)\n`View` that will act as the handle for dragging it (this can be the `View` itself).\n\nXML layout file:\n\n```xml\n\u003ccom.jmedeisis.draglinearlayout.DragLinearLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:id=\"@+id/container\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\" \u003e\n\n    \u003cTextView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"@string/text\" /\u003e\n\n    \u003cImageView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"120dp\"\n        android:scaleType=\"centerCrop\"\n        android:src=\"@drawable/image\"/\u003e\n\n    \u003cButton\n        android:id=\"@+id/button\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"@string/button_text\"/\u003e\n        \n\u003c/com.jmedeisis.draglinearlayout.DragLinearLayout\u003e\n```\n\nEnabling drag \u0026 swap for all child views:\n\n```java\nDragLinearLayout dragLinearLayout = (DragLinearLayout) findViewById(R.id.container);\nfor(int i = 0; i \u003c dragLinearLayout.getChildCount(); i++){\n    View child = dragLinearLayout.getChildAt(i);\n    // the child will act as its own drag handle\n    dragLinearLayout.setViewDraggable(child, child);\n}\n```\n\nUse `#addDragView(View, View)`,`#addDragView(View, View, int)` and `#removeDragView(View)` to\nmanage draggable children dynamically:\n\n```java\nfinal View view = View.inflate(context, R.layout.view_layout, null);\ndragLinearLayout.addDragView(view, view.findViewById(R.id.view_drag_handle));\n\n// ..\n\ndragLinearLayout.removeDragView(view);\n```\n\nAttach an `OnViewSwapListener` with `#setOnViewSwapListener(OnViewSwapListener)` to detect changes\nto the ordering of child `View`s:\n\n```java\ndragLinearLayout.setOnViewSwapListener(new DragLinearLayout.OnViewSwapListener() {\n    @Override\n    public void onSwap(View firstView, int firstPosition,\n            View secondView, int secondPosition) {\n        // update data, etc..\n    }\n});\n```\n\nWhen placing the `DragLinearLayout` inside a `ScrollView`, call `#setContainerScrollView(ScrollView)`\nto enable the user to scroll while dragging a child view.\n\nFor best visual results, use children that have opaque backgrounds. Furthermore, do not use\nhorizontal padding for the `DragLinearLayout`; instead, let children apply their own horizontal\npadding.\n\nRefer to the included sample activity project for a demonstration of the above usage techniques\nand more.\n\nLimitations\n-----------\n- Supports only the `LinearLayout#VERTICAL` orientation.\n\nLicense\n-------\nThis project is licensed under the terms of the MIT license.\nYou may find a copy of the license in the included `LICENSE` file.\n\n[drag_list_1]: https://github.com/bauerca/drag-sort-listview\n[drag_list_2]: https://plus.google.com/u/0/+AndroidDevelopers/posts/7Qo9vmeqKwC\n[drag_list_3]: http://ericharlow.blogspot.com/2010/10/experience-android-drag-and-drop-list.html\n[drag_list_4]: https://github.com/terlici/DragNDropList\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustasm%2FDragLinearLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustasm%2FDragLinearLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustasm%2FDragLinearLayout/lists"}