से पहले देरी को कैसे खत्म कर सकता हूं मैं हनीकॉम में नई LayoutTransition
कक्षा को आजमाने की कोशिश कर रहा हूं। मैंने एक एनीमेशन सेट किया है जो को ViewGroup
पर जोड़ते समय स्थान पर स्लाइड करता है। मैंने देखा कि जब कोई दृश्य पहली बार प्रस्तुत करता है और जब LayoutTransition.APPEARING
एनीमेशन शुरू होता है तो थोड़ी देर (लगभग 20 मिमी) होती है। दूसरे शब्दों में, स्क्रीन पर दृश्य दिखाई देने के बाद, यह एक पल के लिए हवा में लटकता है, और फिर जगह में एनिमेट करना शुरू कर देता है। आप इसे ApiDemos
नमूना प्रोजेक्ट में भी देख सकते हैं। लेआउट एनीमेशन उदाहरणों में, ViewGroup
की अपरिवर्तनीय एनीमेशन शुरू होने से पहले हमेशा देरी होती है। मैंने अन्य LayoutTransition
एनिमेशन को शून्य करने के लिए भी सेट करने का प्रयास किया है, या अंततः उन्हें बहुत कम अवधि दे रहा है, लेकिन फिर भी APPEARING
एनीमेशन में देरी हो रही है। मैं APPEARING
एनीमेशन से पहले देरी कैसे खत्म करने हैलेआउट ट्रांज़िशन एनीमेशन
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Add Button"
android:id="@+id/addNewButton" />
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="match_parent"
android:id="@+id/frame_container" android:animateLayoutChanges="true" />
</LinearLayout>
: यहाँ मेरी कोड है:
public class DebugExampleFour extends Activity {
private int numButtons = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.debug_example_four);
final ViewGroup frame = (ViewGroup) findViewById(R.id.frame_container);
LayoutTransition transitioner = new LayoutTransition();
Animator appearingAnimation = ObjectAnimator.ofFloat(null, "translationX", 600, 0);
appearingAnimation.setDuration(45);
appearingAnimation.setStartDelay(0);
appearingAnimation.setInterpolator(new DecelerateInterpolator());
appearingAnimation.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator anim) {
View view = (View) ((ObjectAnimator) anim).getTarget();
view.setTranslationX(0f);
}
});
transitioner.setAnimator(LayoutTransition.APPEARING, appearingAnimation);
Animator dummyAnimation = ObjectAnimator.ofInt(0, 1);
dummyAnimation.setDuration(1);
dummyAnimation.setStartDelay(0);
transitioner.setAnimator(LayoutTransition.CHANGE_APPEARING, dummyAnimation);
transitioner.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, dummyAnimation);
transitioner.setAnimator(LayoutTransition.DISAPPEARING, dummyAnimation);
frame.setLayoutTransition(transitioner);
Button addButton = (Button) findViewById(R.id.addNewButton);
addButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Button newButton = new Button(DebugExampleFour.this);
newButton.setText("Click To Remove " + (numButtons++));
newButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
frame.removeView(v);
}
});
frame.addView(newButton, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
});
}
}
यहाँ लेआउट फ़ाइल है कि उदाहरण के साथ चला जाता है?
@Chet को स्पष्ट करने के लिए धन्यवाद, मुझे लगता है कि जावाडोक में या आधिकारिक डेवलपर ब्लॉग पर आपकी पोस्ट में उल्लिखित इन अंतर्निहित देरी को देखना उपयोगी होगा। –
अच्छा विचार - मैं डिफ़ॉल्ट व्यवहार/देरी के बारे में बात करने के लिए लेआउट ट्रांजिशन javadocs में कुछ जोड़ दूंगा। –
..... चेट ने सिर्फ मेरे डिजिटल को छुआ ..... – dell116