Android examples for Animation:Animation to Show
show a View with Animation
/*/*from w ww. ja va 2 s. com*/ * Copyright (C) 2015 Krystian Dro?d?y?ski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //package com.java2s; import android.view.View; import android.view.animation.AccelerateInterpolator; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.AnimationSet; import android.view.animation.ScaleAnimation; public class Main { protected static void show(final View view) { Animation fadeIn = new AlphaAnimation(0, 1); fadeIn.setStartOffset(500); fadeIn.setDuration(500); Animation collapse = new ScaleAnimation(1, 1, 0, 1); collapse.setDuration(500); AnimationSet animation = new AnimationSet(false); animation.setInterpolator(new AccelerateInterpolator()); animation.addAnimation(collapse); animation.addAnimation(fadeIn); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); view.startAnimation(animation); } }