title: Android Fragment Oncreateview Loadanimation
body: <p>I created an app, which using InfiniteViewpager by antonyt.</p>
  
  <p>I want to add an Animation on an <code>Imageview</code> when my View is created, but my Animation working a few times, not always. Here's the code:</p>
  
  <pre><code>public class ColourFragment extends Fragment {
  
  
  private int identifier;
  private String logo;
  
  
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Bundle args = getArguments();
  
  identifier = args.getInt("identifier");
  logo = args.getString("logo");
  }
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
      View V = inflater.inflate(R.layout.radiologok, container, false);
  </code></pre>
  
  <p>The <code>ImageView</code> I want to animate.</p>
  
  <pre><code>    ImageView imageView = (ImageView)V.findViewById(R.id.radiologovalaszto); 
  
  
      ProgressBar progressBar = (ProgressBar) V.findViewById(R.id.progressBar1);
  
      DisplayMetrics displaymetrics = new DisplayMetrics();
      getActivity().getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
      int height = displaymetrics.heightPixels / 4 * 3;
      int width = displaymetrics.widthPixels / 4 * 3;  
  
  
      imageView.setAdjustViewBounds(true);
      imageView.getLayoutParams().height = height;
      imageView.getLayoutParams().width = width;
  </code></pre>
  
  <p>Load Android Query library to get image from the web.</p>
  
  <pre><code>   AQuery aq = new AQuery(getActivity());
     AQUtility.setDebug(true);
     aq.hardwareAccelerated11();
  </code></pre>
  
  <p>The image is set.</p>
  
  <pre><code>aq.id(imageView).progress(progressBar).image(logo, true, true, width, 0);
  </code></pre>
  
  <p>Here i want to add the <code>Animation</code>   </p>
  
  <pre><code>    Animation pulse = AnimationUtils.loadAnimation(getActivity(), R.anim.pulse);
  imageView.startAnimation(pulse);
  
      Return V;
  </code></pre>
  
  <p>}</p>
  
  <p>Here's my Animation:</p>
  
  <pre><code>&lt;set xmlns:android="http://schemas.android.com/apk/res/android"
  android:shareInterpolator="false" &gt;
  &lt;scale
      android:duration="1000"
      android:fromXScale="1"
      android:fromYScale="1"
      android:pivotX="50%"
      android:pivotY="50%"
      android:toXScale="0.5"
      android:toYScale="0.5" /&gt;
  &lt;scale
      android:duration="1000"
      android:fromXScale="1"
      android:fromYScale="1"
      android:pivotX="50%"
      android:pivotY="50%"
      android:startOffset="1000"
      android:toXScale="2"
      android:toYScale="2" /&gt;
     &lt;/set&gt;
  </code></pre>
  
  <p>I load the view by using a fragmentadapter:</p>
  
  <pre><code> final PagerAdapter adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
  
                  @Override
                  public int getCount() {
                  return Radiologos.length;
                  }
  
                  @Override
                  public Fragment getItem(int position) {
                  Fragment fragment = new ColourFragment();
                  Bundle args = new Bundle();
  
                  args.putString("logo", Radiologos[position]);
                  args.putInt("identifier", position);
                  fragment.setArguments(args);
                  return fragment;
                  }
              };
  </code></pre>