ポップアップがあり、最初は画面の右側に配置したいのですが、まだドラッグできます。
重力を中央に設定すると、問題なく移動できます
LinearLayout l = initNoteLayout(context);
mNotePopup = new PopupWindow(l, 650, 370, true);
l.setOnTouchListener(new OnTouchListener() {
private int dx = 0;
private int dy = 0;
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
dx = (int) motionEvent.getRawX();
dy = (int) motionEvent.getRawY();
break;
case MotionEvent.ACTION_MOVE:
int x = (int) motionEvent.getRawX();
int y = (int) motionEvent.getRawY();
int left = (x - dx);
int top = (y - dy);
//Log.d("test", "x: " + left + " y: " + top);
mNotePopup.update(left, top, -1, -1);
break;
}
return true;
}
});
mNotePopup.showAtLocation(l, Gravity.CENTER, 0, 0);
これは機能しますが、画面の中央にあります。私が設定した場合
mNotePopup.showAtLocation(l, Gravity.RIGHT, 0, 0);
必要な場所に表示され、上下にドラッグできますが、右側に接着されています。
何か案は?考えられる重力フラグのすべての組み合わせを試しました
ありがとう