DragLinearLayout


Source link: https://github.com/justasm/DragLinearLayout

DragLinearLayout

An Android LinearLayout that supports draggable and swappable child Views.

Why?

Why bother doing drag & swap in a LinearLayout when there are so many solutions for ListView?

  1. Simplicity - no need for ListAdapters. By default, works like a LinearLayout.
  2. Flexibility - supports heterogeneous, selectively draggable (or not draggable), children.
  3. Portability - can be used in any layout, e.g. as a child in a ScrollView container.

Usage

Add it to your project using Gradle:

compile 'com.jmedeisis:draglinearlayout:1.1.0'

The DragLinearLayout can be used in place of any LinearLayout. However, by default, children will not be draggable. To set an existing View as draggable, use DragLinearLayout#setViewDraggable(View, View), passing in the child View and a (non-null!) View that will act as the handle for dragging it (this can be the View itself).

XML layout file:

<com.jmedeisis.draglinearlayout.DragLinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/container"
  android:layout_width="match_parent"
  android:layout_height="match_parent" >

<TextView

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="@string/text" />

<ImageView

android:layout_width="match_parent"

android:layout_height="120dp"

android:scaleType="centerCrop"

android:src="@drawable/image"/>

<Button

android:id="@+id/button"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="@string/button_text"/>

 </com.jmedeisis.draglinearlayout.DragLinearLayout>

Enabling drag & swap for all child views:

DragLinearLayout dragLinearLayout = (DragLinearLayout) findViewById(R.id.container);
 for(int i = 0; i < dragLinearLayout.getChildCount();
 i++){

  View child = dragLinearLayout.getChildAt(i);

  // the child will act as its own drag handle
  dragLinearLayout.setViewDraggable(child, child);
 
}

Use #addDragView(View, View), #addDragView(View, View, int) and #removeDragView(View) to manage draggable children dynamically:

final View view = View.inflate(context, R.layout.view_layout, null);
 dragLinearLayout.addDragView(view, view.findViewById(R.id.view_drag_handle));
  // ..  dragLinearLayout.removeDragView(view);

Attach an OnViewSwapListener with #setOnViewSwapListener(OnViewSwapListener) to detect changes to the ordering of child Views:

dragLinearLayout.setOnViewSwapListener(new DragLinearLayout.OnViewSwapListener() {

  @Override
  public void onSwap(View firstView, int firstPosition,

 View secondView, int secondPosition) {

// update data, etc..
  
}
 
}
);

When placing the DragLinearLayout inside a ScrollView, call #setContainerScrollView(ScrollView) to enable the user to scroll while dragging a child view.

For best visual results, use children that have opaque backgrounds. Furthermore, do not use horizontal padding for the DragLinearLayout; instead, let children apply their own horizontal padding.

Refer to the included sample activity project for a demonstration of the above usage techniques and more.

Limitations

  • Supports only the LinearLayout#VERTICAL orientation.

License

This project is licensed under the terms of the MIT license. You may find a copy of the license in the included LICENSE file.

Resources

Godot is a fully featured game engine. It focuses on having great tools, and a visual oriented workflow that can export to PC, Mobile and Web platforms with no hassle. The editor, language and APIs are feature rich, yet simple to learn, allowing you to become productive in a matter of hours.

Sample project created to reinforce some of the main concepts described in the tech talk "Effective Android UI".

AnUitor is a result of my rebranding experiences of one android app what i was working on. Because of structure of project(s), not using themes, complexity of UI and app itself, it was really hell and time consuming work to finish app rebranding. Project structure had been done like sub-projects, because of big amount of different assets, logic, etc. I found out also AnUitor very useful in time of UI refactoring/bugfixing other apps what i didn't know much deeply from UI perspective.

Boilerplate code suppressor tool for Android platform based on Project Lombok.

DobList is an Open Source Android library that provides to ListView adding ProgressBar (or any view) to the footer of ListView to be shown in loading more, and callback that is called when reaching last item in ListView.

There are more than one horizontal sliding menu library for Android, but what about a vertical sliding?

DobSliding is an Open Source Android library that allows developers to develop applications with vertical sliding menus just like the Android notifications menu.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes