Falling animation is used to bring transition to a view between two X points or two Y points. In Android, you can apply this scaling effect to almost anything, from simple text, to images, buttons, etc…
in res/anim/falling.xml
suppose if transition to be done between two different X indexes use..
in res/anim/falling.xml
suppose if transition to be done between two different X indexes use..
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator"> <translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="2000"/> </set>suppose if transition to be done between two different Y indexes use..
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator"> <translate android:fromYDelta="-100%p" android:toYDelta="0" android:duration="2000"/> </set>The java source code is given below
public class Textviewanimation extends Activity { TextView tv; Button startanimation; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_textviewanimation); tv=(TextView) findViewById(R.id.textview); startanimation=(Button) findViewById(R.id.button1); tv.setText("Android is a Linux-based operating system designed primarily for touchscreen mobile devices such as smartphones and tablet computers."); final Animation falling = AnimationUtils.loadAnimation(this,R.anim.falling); startanimation.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { tv.startAnimation(falling); } }); } }
see more :
Comments
Post a Comment