我需要创建一个UI,允许用户通过拖动来调整布局。不幸的是,我没有足够的声誉来添加图像来解释我想要实现的目标,所以这是一个原理图。
|-----------------|
| | |
|P1 | |
| | MapView |
|---| |
| P2| |
|-----------------|
这是布局的总体轮廓。 P1和P2是可拖动的面板,这意味着它们应该是动态可调的。谁能给我任何关于如何解决这个问题的指示?
答案 0 :(得分:1)
我猜你是初学者..这是可以帮助你的方法..
private final class MyTouchListener implements OnTouchListener { public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
ClipData data = ClipData.newPlainText("", "");
DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
view.startDrag(data, shadowBuilder, view, 0);
view.setVisibility(View.INVISIBLE);
return true;
} else {
return false;
} } }
OR
这是链接
http://www.vogella.com/articles/AndroidDragAndDrop/article.html
http://www.edumobile.org/android/android-beginner-tutorials/drag-and-drop-ui-element/