Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I eliminate the delay before an LayoutTransition animation
    primarykey
    data
    text
    <p>I'm trying out the new <code>LayoutTransition</code> class in Honeycomb. I have set an animation that slides a <code>View</code> into place when adding it to a <code>ViewGroup</code>. I noticed that there is a slight delay (around 20ms) between when a view first renders and when the <code>LayoutTransition.APPEARING</code> animation begins. In other words, after the view appears on screen, it hangs in the air for a moment, and then starts to animate into place. You can notice this even in the <code>ApiDemos</code> sample project. In the layout animation examples, there's always a delay before a <code>ViewGroup</code>'s APPEARING animation starts. I've even tried setting the other <code>LayoutTransition</code> animations to null, or finally giving them very short durations, but still the <code>APPEARING</code> animation is delayed. Here's my code:</p> <pre><code>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)); } }); } } </code></pre> <p>Here's the layout file that goes along with the example:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Add Button" android:id="@+id/addNewButton" /&gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/frame_container" android:animateLayoutChanges="true" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>How do I eliminate the delay before the <code>APPEARING</code> animation?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload