Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.support.v4.app.FragmentActivity;
import android.util.DisplayMetrics;
import android.view.View;

import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;

import android.view.animation.LinearInterpolator;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;

public class Main {
    public static void enlargeToRight(FragmentActivity activity, View view, AnimationListener listener) {

        DisplayMetrics displaymetrics = new DisplayMetrics();
        activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
        int screenHeight = displaymetrics.heightPixels;
        int screenWidth = displaymetrics.widthPixels;

        AnimationSet animation = new AnimationSet(true);
        float pivotX = view.getWidth() / 2;
        float pivotY = view.getHeight() / 2;
        ScaleAnimation anim = new ScaleAnimation(0.8f, 1f, 0.8f, 1f, pivotX, pivotY);
        anim.setInterpolator(new LinearInterpolator());
        anim.setDuration(200);
        anim.setStartOffset(200);
        //anim.setFillAfter(true);
        animation.addAnimation(anim);

        TranslateAnimation animTrans = new TranslateAnimation(0.0f, (float) (screenWidth - view.getWidth()), 0.0f,
                0.0f);
        anim.setInterpolator(new LinearInterpolator());
        animTrans.setDuration(400);
        //animTrans.setStartOffset(300);
        animation.addAnimation(animTrans);

        if (listener != null)
            animation.setAnimationListener(listener);

        view.startAnimation(animation);
    }
}