Tuesday 6 March 2012

Android Title Animaion

package popupshow.deepak;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewParent;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.widget.TextView;
import android.widget.Toast;

public class PopupshowActivity extends Activity {
   
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
       
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
      //Get The Title
        View title=getWindow().findViewById(android.R.id.title);
            
        ViewParent parent=title.getParent();
         View parentview=(View)parent;
        parentview.setBackgroundColor(Color.rgb(100, 149, 237));
        Animation hyper=AnimationUtils.loadAnimation(this,android.R.anim.fade_out);

 //Creating animation object for transition of title 
        Animation isfromleft= new TranslateAnimation(Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
        isfromleft.setDuration(10000);
        isfromleft.setInterpolator(new AccelerateInterpolator());
        isfromleft.setAnimationListener(animater);
       
       
          parentview.setAnimation(isfromleft);
   
              
       
       
    }
   
    private Animation.AnimationListener animater=new Animation.AnimationListener() {
       
        @Override
        public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub
           
        }
       
        @Override
        public void onAnimationRepeat(Animation animation) {
           
           
        }
       
        @Override
        public void onAnimationEnd(Animation animation) {
            animation.start();
           
           
        }
    };   
   
}

No comments:

Post a Comment