Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.primus.layoutitemanimation;
- import android.content.ClipData;
- import android.util.Log;
- import android.view.MotionEvent;
- import android.view.View;
- import android.view.View.DragShadowBuilder;
- import android.view.View.OnTouchListener;
- public class MyTouchListener implements OnTouchListener {
- public static int view_position=0;
- public static View first_image_view;
- public static int first_last_touch_x_axis,first_last_touch_y_axis;
- @Override
- public boolean onTouch(View view, MotionEvent event) {
- // TODO Auto-generated method stub
- view_position=view.getId();
- first_image_view=view;
- first_last_touch_x_axis=(int) event.getX();
- first_last_touch_y_axis=(int) event.getY();
- if(event.getActionMasked()==MotionEvent.ACTION_DOWN)
- {
- ClipData data = ClipData.newPlainText("", "");
- DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
- view.startDrag(data, shadowBuilder, view, 0);
- view.setVisibility(View.VISIBLE);
- Log.e("TOUCH", "down");
- Log.e("X_AXIS,Y_AXIS",".."+first_last_touch_x_axis+","+first_last_touch_y_axis);
- return true;
- }
- else if(event.getActionMasked()==MotionEvent.ACTION_UP)
- {
- first_last_touch_x_axis=0;
- first_last_touch_y_axis=0;
- Log.e("TOUCH", "UP");
- return true;
- }
- else if(event.getActionMasked()==MotionEvent.ACTION_MOVE)
- {
- Log.e("TOUCH", "MOVE");
- return true;
- }
- return true;
- }
- // @Override
- // public boolean onLongClick(View view) {
- //
- // ClipData data = ClipData.newPlainText("", "");
- // DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
- // view.startDrag(data, shadowBuilder, view, 0);
- // view.setVisibility(View.VISIBLE);
- // view_position=view.getId();
- // first_x_axis=(int) view.getX();
- // first_y_axis=(int) view.getY();
- // first_image_view=view;
- // Log.v("IMAGE TOUCH", "CLICKED"+".."+first_x_axis+".."+first_y_axis);
- // return true;
- //
- //
- //
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement