title: Android: Start animation after fragment is completely loaded
body: <p>I have a fragment that has an animation of textView fadein. The animation must start after some time delay say 2 seconds after fragment is loaded. I wrote a code for this. but the animation part is done and then the view is rendered. How can I load the fragment and after some time delay start my animation</p>
  
  <p>My code is as below: <strong>Note:</strong> the class extends <strong>Fragment</strong></p>
  
  <pre><code>Animation animFadein;
  MenuClickHelper mClickHelper;
  TextView tv;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      final View rootView = inflater.inflate(R.layout.fragment_main_menu,
              container, false);
  
      mClickHelper = new MenuClickHelper(rootView, getFragmentManager());
  
      tv = (TextView) rootView.findViewById(R.id.tvPresentation);
      animFadein = AnimationUtils.loadAnimation(getActivity()
              .getApplicationContext(), R.anim.fade_in);
  
      animFadein.setAnimationListener(new AnimationListener() {
  
          @Override
          public void onAnimationStart(Animation animation) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void onAnimationRepeat(Animation animation) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void onAnimationEnd(Animation animation) {
              if (animation == animFadein) {
                  Toast.makeText(getActivity().getApplicationContext(),
                          "Animation Stopped", Toast.LENGTH_SHORT).show();
              }
          }
      });
  
      try {
          Thread.sleep(2000);
          tv.startAnimation(animFadein);
      } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      return rootView;
  }
  </code></pre>