Note that there are some explanatory texts on larger screens.

plurals
  1. POImage Animation Failed to play
    primarykey
    data
    text
    <p>I have used below code to play image animation. But after clicking button, animation couldn't play. Note : I have put rotator.xml in res/anim folder.</p> <p><strong>AnimationActivity.java</strong></p> <pre><code>package com.example.animationdemo; import android.os.Bundle; import android.app.Activity; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.Button; import android.widget.ImageView; public class AnimationActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_animation); ((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { final ImageView myImage = (ImageView)findViewById(R.id.imageView1); final Animation myRotation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotator); myImage.startAnimation(myRotation); } }); } } </code></pre> <p><strong>rotator.xml :</strong></p> <pre><code>&lt;rotate xmlns:android="”http://schemas.android.com/apk/res/android”"&gt; android:duration="”4000”" android:fromdegrees="”0”" android:pivotx="”50%”" android:pivoty="”50%”" android:todegrees="”360”" android:toyscale="”0.0”" &lt;/rotate&gt; </code></pre> <p><strong>activity_animation.xml</strong> :</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".AnimationActivity" &gt; &lt;ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="51dp" android:layout_marginTop="95dp" android:src="@drawable/ic_launcher" /&gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="109dp" android:layout_toRightOf="@+id/imageView1" android:text="OK" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p><strong>AndroidManifest.xml</strong> </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.animationdemo" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.animationdemo.AnimationActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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