Home>
There are two images iv1 and iv2 on Framelayout. iv1 supports pitch in/out and scales. However, iv2 cannot handle pitch in/out due to animation. Somehow, I want to support pitch-in/out during the animation, what should I do?
I also want to synchronize the positional relationship between iv1 and iv2 if there is room.
Source codeprivate ScaleGestureDetector detector;
private float scale = 1f;
private ImageView imageView1;
private ImageView imageView2;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
imageView1 = findViewById (R.id.imageview1);
imageView2 = findViewById (R.id.imageview2);
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat (imageView2, "translationX", 0f, 1000f);
objectAnimator.setDuration (1000);
objectAnimator.setRepeatCount (ValueAnimator.INFINITE);
objectAnimator.start ();
detector = new ScaleGestureDetector (this, new ScaleListener ());
}
public boolean onTouchEvent (MotionEvent event) {
detector.onTouchEvent (event);
return super.onTouchEvent (event);
}
private class ScaleListener
extends ScaleGestureDetector.SimpleOnScaleGestureListener {
@Override
public boolean onScale (ScaleGestureDetector detector) {
scale * = detector.getScaleFactor ();
imageView1.setScaleX (scale);
imageView1.setScaleY (scale);
return true;
}
}
-
Answer # 1
Related articles
Related questions
- assuming that there are 3 android apps [java] buttons and a switch, they are managed by the switch statement button responds, bu
- java - listview is not displayed
- java - how to access the onclick method
- java - i want to open a word file from an android app in another app, edit it, and save it
- java - i want to put the data acquired using sqlitedatabase in the text box
- java - crash with nullpointerexception when alarm is activated on android o or later
- java - is it possible to create a circular scroll bar?
- java - i want to load a kml file into android studio and display the feature data on google map
- java - regarding the compatibility between system overlay and recyclerview
- java - data transfer between activities is not reflected
I could do what I wanted to do if I was messed up. Please use it for your coding.