Tampilkan postingan dengan label Android animation. Tampilkan semua postingan
Tampilkan postingan dengan label Android animation. Tampilkan semua postingan

Falling Animation in ANDROID using Animation of Translate

Posted by Unknown Sabtu, 20 April 2013 0 komentar
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..
 
<?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 :

Baca Selengkapnya ....

Scaling Animation In ANDROID

Posted by Unknown Jumat, 19 April 2013 0 komentar
Scaling animation is used to scale a view. In Android, you can apply this scaling effect to almost anything, from simple text, to images, buttons, etc…

 Here simply I will explain a scaling textview which you can apply to other views also... In res/anim/scale.xml
 
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<scale
android:fromXScale="0.0"
android:toXScale="1.0"
android:fromYScale="0.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="2000" />
</set>
Java source code is given below
 
public class Textviewanimation extends Activity {
Animation fadeIn,fadeOut;
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("This is an animated textview");

final Animation Scale = AnimationUtils.loadAnimation(this,R.anim.scale);
startanimation.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
tv.startAnimation(Scale);
}
}); }
}
see more: 

Baca Selengkapnya ....

TextView Animation or Alpha animation (FadeIn , FadeOut) in ANDROID

Posted by Unknown 0 komentar
An Alpha Animation is animation that controls the alpha level of an object, i.e. fading it in and out. In Android, you can apply that fading effect to almost anything, from simple text, to images, buttons, check boxes, etc…
 
This can be done both from xml and from java class.

Here I will explain a simple way to give a FadeIn and FadeOut for a textview on button click..
 

public class Textviewanimation extends Activity {

Animation fadeIn,fadeOut;
TextView tv;
Button startanimation;
Boolean fadeflag=true;

@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);

fadeIn = new AlphaAnimation(0.0f , 1.0f ) ;
fadeIn.setDuration(1200);
fadeIn.setFillAfter(true);

fadeOut = new AlphaAnimation(1.0f , 0.0f);
fadeOut.setDuration(1200);
fadeOut.setFillAfter(true);

startanimation.setText("Start fadeIn");
startanimation.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {

if(fadeflag)
{
startanimation.setText("Start fadeOut");
tv.setText("This is an animated textview");
tv.startAnimation(fadeIn);
fadeflag=false;
}
else
{
startanimation.setText("Start fadeIn");
tv.setText("This is an animated textview");
tv.startAnimation(fadeOut);
fadeflag=true;
} } });
}
}

This same can be done with xml by creating an xml in res/anim/fadein
 




and res/anim/fadeout
 




Then in java
 
Animation animationFadeIn = AnimationUtils.loadAnimation(this,R.anim.fadein);
tv.startAnimation(animationFadeIn);
same way call the other

see more 
Falling animation ..

Baca Selengkapnya ....
Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android populer.