从屏幕底部向上滑出一个view的方式,主要是使用TranslateAnimation,这个类,可以绑定一个控件,在y轴方向,滑出一段高度,如下代码: package com.txlong;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.TextView;
public class AndroidAnimationActivity extends Activity {
private Animation myAnimation_Translate;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final TextView tv = (TextView) findViewById(R.id.tv);
Button btn = (Button) findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv.setVisibility(View.VISIBLE);
myAnimation_Translate = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, -1,
Animation.RELATIVE_TO_PARENT, 0,
Animation.RELATIVE_TO_PARENT, 0,
Animation.RELATIVE_TO_PARENT, 0);
myAnimation_Translate.setDuration(1000);
myAnimation_Translate.setInterpolator(AnimationUtils
.loadInterpolator(AndroidAnimationActivity.this,
android.R.anim.accelerate_decelerate_interpolator));
tv.startAnimation(myAnimation_Translate);
}
});
}
}