You can remove views from layouts and add them to other layouts (if that's what you are looking for)
ViewGroup oldGroup = (ViewGroup) findViewById(R.id.some_layout); ViewGroup newGroup = (ViewGroup) findViewById(R.id.some_other_layout); Button button = (Button) oldGroup.findViewById(R.id.a_button); oldGroup.removeView(button); newGroup.addView(button);
There are no drag and drop animations, and this may give strange results, but it is possible.
A ViewGroup will be LinearLayout , RelativeLayout and those.
To model Drag & Drop events, you can call onDragListener manually, but there is one problem:
public boolean onDrag(View v, DragEvent event);
expects a DragEvent that has no public constructor, so you can only call it null
There may be a way to create it through a fake batch, but it will be ugly.
private void initializationTest() { DragEvent event = null; onDrag(theTargetView, event); }
Another possibility is to maybe create touches, but Idk if that works. Perhaps it is possible monkey .
source share