Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Either post code or check out the <a href="http://developer.android.com/guide/topics/resources/animation-resource.html#translate-element" rel="nofollow">documentation</a> on what you're asking and get a little more descriptive. This isn't a vending machine for code, people generally don't want to just code things for people because they ask for it. What exactly are you having problems with would be a good start? Please read documents, try again and if you can't get it come back with details; you'll find help quicker.</p> <p>[edit]----tutorial below-----</p> <p>Since you've actually given some level of detail here I suppose I'll show you a simple method. First, <a href="http://www.hascode.com/2010/09/playing-around-with-the-android-animation-framework/" rel="nofollow"><code>this</code></a> is a great place for animation information. Use it. Second, this code worked perfect for me on the Droid2.</p> <pre><code>public class animationTEST extends Activity implements AnimationListener { LinearLayout layout; LinearLayout layout2; Animation movement; Animation movement2; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Get the layouts layout = (LinearLayout) findViewById(R.id.linearLayout1); layout2 = (LinearLayout) findViewById(R.id.linearLayout2); // Create animation for right image movement = AnimationUtils.loadAnimation(this, R.layout.animation_test); movement.reset(); movement.setAnimationListener(this); // Create animation for left image movement2 = AnimationUtils.loadAnimation(this, R.layout.animation_test2); movement2.reset(); movement2.setAnimationListener(this); // Start animation on each image layout2.startAnimation(movement2); layout.startAnimation(movement);} // Listen for animations to be finished // There are more efficient ways, I'm just being lazy. public void onAnimationEnd(Animation animation) { layout.setVisibility(View.INVISIBLE); layout2.setVisibility(View.INVISIBLE); // or do whatever it is you wanted to do here, like launch another activity? } public void onAnimationRepeat(Animation animation) { } public void onAnimationStart(Animation animation) { } } </code></pre> <p>The <code>main.xml</code> file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Animation Test Activity" /&gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/relativeLayout1"&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginLeft="105dip" android:id="@+id/linearLayout2"&gt; &lt;ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon" android:layout_marginRight="30dip" android:id="@+id/imageView2"&gt;&lt;/ImageView&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:id="@+id/linearLayout1" android:layout_marginLeft="145dip"&gt; &lt;ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon" android:layout_marginRight="30dip" android:id="@+id/imageView1"&gt;&lt;/ImageView&gt; &lt;/LinearLayout&gt; &lt;/RelativeLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>The <code>animation_test.xml</code> (defining translate animation)</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromXDelta="0" android:toXDelta="65%p" android:fromYDelta="0" android:toYDelta="0%" android:duration="3000" android:zAdjustment="top"/&gt; </code></pre> <p>The <code>animation_test2.xml</code></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromXDelta="0" android:toXDelta="-65%p" android:fromYDelta="0" android:toYDelta="0%" android:duration="3000" android:zAdjustment="top"/&gt; </code></pre> <p>If you can't understand this, go back and read both documents I've given you. There is enough information here to understand just about any of the animations. However, your wanting to use <code>animationDrawable</code> objects isn't right, because that's a frame animation, not a transformation or motion. Frame based animation is simply making something look like it's dancing, or waving. When you're trying to simply move, fade, or scale an image you want transformation animations. Hope this helps! </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.
 

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