উত্তর:
আপনি যাকে কল clearAnimation()
করেছেন কল করুন ।View
startAnimation()
setFillAfter()
সম্ভবত আপনি যা মনে করেন তা করেন না। যখন স্পর্শ ইভেন্টটি ঘটে তখন অ্যানিমেশনটি সাফ করুন এবং তারপরে আপনি যে স্থায়ী পরিবর্তন চান তা প্রভাবিত করতে আপনার বিন্যাসটি সামঞ্জস্য করুন।
অ্যান্ড্রয়েড ৪.৪.৪ এ, ভিউতে কল করা View.animate().cancel()
(যেমন, ভিউগুলিতে ফোন .cancel()
করা ViewPropertyAnimator
) একমাত্র আলফা ফিডিং অ্যানিমেশনটি থামাতে পারার একমাত্র উপায় বলে মনে হয় ।
আমি আইসিএসের আগে এবং পরে সামঞ্জস্যতার জন্য কোডটি ব্যবহার করছি:
public void stopAnimation(View v) {
v.clearAnimation();
if (canCancelAnimation()) {
v.animate().cancel();
}
}
... পদ্ধতি সহ:
/**
* Returns true if the API level supports canceling existing animations via the
* ViewPropertyAnimator, and false if it does not
* @return true if the API level supports canceling existing animations via the
* ViewPropertyAnimator, and false if it does not
*/
public static boolean canCancelAnimation() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
}
আমি যে অ্যানিমেশনটি থামিয়ে দিচ্ছি তা এখানে:
v.setAlpha(0f);
v.setVisibility(View.VISIBLE);
// Animate the content view to 100% opacity, and clear any animation listener set on the view.
v.animate()
.alpha(1f)
.setDuration(animationDuration)
.setListener(null);
.setListener(null);
এটি আমাকে সাহায্য করেছে।
আপনি যদি অ্যানিমেশন শ্রোতা ব্যবহার করেন তবে সেট করুন v.setAnimationListener(null)
। সমস্ত অপশন সহ নিম্নলিখিত কোডটি ব্যবহার করুন।
v.getAnimation().cancel();
v.clearAnimation();
animation.setAnimationListener(null);
v.setAnimation(null);
কারণ এটি সম্পন্ন হবে v.clearAnimation();
।
আপনি যা করতে চেষ্টা করতে পারেন তা হল অ্যানিমেশনটি বন্ধ করার আগে রূপান্তর ম্যাট্রিক্স পাওয়া এবং আপনি যে অবস্থানের মানগুলি সন্ধান করছেন তা পাওয়ার জন্য ম্যাট্রিক্স সামগ্রীগুলি পরীক্ষা করে।
এখানে আপনার দেখা উচিত এপিআই
public boolean getTransformation (long currentTime, Transformation outTransformation)
public void getValues (float[] values)
সুতরাং উদাহরণস্বরূপ (কিছু ছদ্ম কোড। আমি এটি পরীক্ষা করেছি না):
Transformation outTransformation = new Transformation();
myAnimation.getTransformation(currentTime, outTransformation);
Matrix transformationMatrix = outTransformation.getMatrix();
float[] matrixValues = new float[9];
transformationMatrix.getValues(matrixValues);
float transX = matrixValues[Matrix.MTRANS_X];
float transY = matrixValues[Matrix.MTRANS_Y];
অ্যানিমেশন বন্ধ করার জন্য সেট অ্যানিমেশন (নাল) পদ্ধতিটি ব্যবহার করুন , এটি View.java তে সর্বজনীন পদ্ধতি হিসাবে প্রকাশিত হয়েছে
, এটি সমস্ত উইজেটের জন্য বেস শ্রেণি , যা ইন্টারেক্টিভ ইউআই উপাদান তৈরি করতে ব্যবহৃত হয় (বোতাম, পাঠ্য ক্ষেত্র, ইত্যাদি)।
/**
* Sets the next animation to play for this view.
* If you want the animation to play immediately, use
* {@link #startAnimation(android.view.animation.Animation)} instead.
* This method provides allows fine-grained
* control over the start time and invalidation, but you
* must make sure that 1) the animation has a start time set, and
* 2) the view's parent (which controls animations on its children)
* will be invalidated when the animation is supposed to
* start.
*
* @param animation The next animation, or null.
*/
public void setAnimation(Animation animation)
অ্যানিমেশন বন্ধ করতে আপনি এমন বস্তুঅ্যানিম্যাটর সেট করতে পারেন যা কিছুই না করে, যেমন
প্রথমে যখন ম্যানুয়াল ফ্লিপিং থাকে সেখানে ডানদিকে থেকে অ্যানিমেশন থাকে:
flipper.setInAnimation(leftIn);
flipper.setOutAnimation(rightOut);
তারপরে অটো ফ্লিপ করার সময় কোনও অ্যানিমেশন নেই
flipper.setInAnimation(doNothing);
flipper.setOutAnimation(doNothing);
doNothing = ObjectAnimator.ofFloat(flipper, "x", 0f, 0f).setDuration(flipperSwipingDuration);