How to do this.. slide down, relace

Problems with Canvas, OpenGL, etc...

How to do this.. slide down, relace

Postby Newbie007 » Wed Mar 16, 2011 4:37 am

Hi,

I am learning Android so still very much a newbie.

So far I can make something slide down via a "Translate" animation, I slide some text or picture down in 6seconds,
but if the user clicks in that 6 seconds I want to immediately replace the current animation (translate.xml) with some_other_animation.xml exactly from that position.

How do I do this? Links or suggestions are most welcome!

Thanks!
Ryan

My code:
Strings.xml
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Just a sample string!</string>
<string name="app_name">Ryan Sample</string>

</resources>


Manifest
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.ryan.test.animsxx"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".AnimationActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

    </application>
</manifest>


AnimationActivity.java
Code: Select all
package com.ryan.test.animsxx;

import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.TextView;

public class AnimationActivity extends Activity {
    /** Called when the activity is first created. */
    @Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final Animation a = AnimationUtils.loadAnimation(this, R.anim.translate);
    a.reset();
    final TextView rText = (TextView) findViewById(R.id.animatedText);
   
    LinearLayout layout = (LinearLayout) findViewById(R.id.root);
    layout.setOnClickListener(new OnClickListener() {
    @Override public void onClick(View v) {
    rText.startAnimation(a);
   
    }
    });
   
    }
   }


Translate.xml
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0%" android:toXDelta="0%" android:fromYDelta="0%"
android:toYDelta="300%" android:duration="3000" android:zAdjustment="bottom" />


Main.xml
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/root"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="top|center">
    <TextView android:id="@+id/animatedText" android:layout_height="wrap_content" android:text="@string/hello" android:layout_width="wrap_content"></TextView>
</LinearLayout>
Newbie007
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Mar 16, 2011 4:19 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 2 guests