对组件进行绑定TouchEvent事件,监测触屏位置为point,再将组件位置设置为point
重写接口方法
public class Forward implements Component.TouchEventListener {
@Override
public boolean onTouchEvent(Component component, TouchEvent touchEvent) {
int action = touchEvent.getAction();
MmiPoint point = touchEvent.getPointerScreenPosition(0);
int x,y;
x = (int) point.getX();
y = (int) point.getY();
if (action == TouchEvent.POINT_MOVE){
component.setPosition(x, y);
}
return true;
}
}
此时存在问题 getPointerScreenPosition 得到的位置坐标是相对于整个屏幕,但是此时DirectionalLayout布局上边还有一部分TItle块,而设