Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- btn.setOnTouchListener(new OnTouchListener() {
- @Override
- public boolean onTouch(View view, MotionEvent me) {
- if (me.getAction() == MotionEvent.ACTION_DOWN) {
- status = START_DRAGGING;
- }
- if (me.getAction() == MotionEvent.ACTION_UP) {
- status = STOP_DRAGGING;
- Log.i("Drag", "Stopped Dragging");
- } else if (me.getAction() == MotionEvent.ACTION_MOVE) {
- if (status == START_DRAGGING) {
- System.out.println("Dragging");
- GestureImageView image1 = (GestureImageView) findViewById(R.id.image1);
- GestureImageView image2 = (GestureImageView) findViewById(R.id.image2);
- ImageView header = (ImageView) findViewById(R.id.imageHeader);
- RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT);
- lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
- margin1 = (int) me.getRawY() - 100;
- if (margin1 < header.getHeight() - btn.getHeight() / 3)
- margin1 = header.getHeight() - btn.getHeight() / 3;
- else if (margin1 > layout.getHeight() - 1.5
- * btn.getHeight() - btn3.getHeight())
- margin1 = (int) (layout.getHeight() - 1.5
- * btn.getHeight() - btn3.getHeight());
- lp.topMargin = margin1;
- btn.setLayoutParams(lp);
- if (margin1 >= margin2 - 35) {
- RelativeLayout.LayoutParams newlp = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT);
- newlp.addRule(RelativeLayout.CENTER_HORIZONTAL);
- margin2 = margin1 + 35;
- newlp.topMargin = margin2;
- btn2.setLayoutParams(newlp);
- RelativeLayout.LayoutParams newlp2 = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.FILL_PARENT);
- newlp2.addRule(RelativeLayout.ABOVE, btn2.getId());
- newlp2.addRule(RelativeLayout.BELOW, header.getId());
- newlp2.bottomMargin = -(15 + margin2);
- image2.setLayoutParams(newlp2);
- image2.setAdditionalY(image2.getHeight(),
- margin2 - 85, image2.getScaledHeight()
- - margin2 - 85);
- }
- RelativeLayout.LayoutParams lp3 = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.FILL_PARENT);
- lp3.addRule(RelativeLayout.ABOVE, btn.getId());
- lp3.addRule(RelativeLayout.BELOW, header.getId());
- lp3.bottomMargin = -(15 + margin1);
- image1.setLayoutParams(lp3);
- image1.setAdditionalY(image1.getHeight(), margin1 - 50,
- image1.getScaledHeight() - margin1 - 50);
- }
- }
- return false;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement