移动动画 移动之后停留在那里
来源:互联网 发布:决胜网seo 编辑:程序博客网 时间:2024/06/05 19:48
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="0dp"
android:layout_y="460dp" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="271dp"
android:layout_height="wrap_content"
android:layout_x="8dp"
android:layout_y="380dp" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.45"
android:text="收起" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.45"
android:text="更多" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_x="0dp"
android:layout_y="0dp"
android:orientation="vertical" android:id="@+id/plxi_plug">
</LinearLayout>
</AbsoluteLayout>
package gt.gt;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
public class AnimationActivity extends Activity {
ImageView iv;
AnimationDrawable ad;
View view;
ListView lv;
private Animation mTranslateAnimation = null;
MyAdapter myAdapter;
Button button1,button2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
DisplayMetrics dm;
dm = this.getApplicationContext().getResources()
.getDisplayMetrics();
_screenWidth = dm.widthPixels;
_screenHeight = dm.heightPixels;
} catch (Exception e) {
}
button1=(Button) findViewById(R.id.button1);
button2=(Button) findViewById(R.id.button2);
button2.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
Intent intent = new Intent(AnimationActivity.this,
com.mini.box.ui.rslist.ResourceListActivity.class);
startActivity(intent);
}
});
lv = new ListView(this);
LinearLayout mailLayout = (LinearLayout)findViewById(R.id.plxi_plug);
iv = (ImageView) findViewById(R.id.imageView1);
iv.setBackgroundResource(R.anim.photos);
ad = (AnimationDrawable) iv.getBackground();
myAdapter = new MyAdapter(this, R.layout.row);
lv.setAdapter(myAdapter);
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(View.VISIBLE==lv.getVisibility() ){
scrolldown(); //移动动画
}else{
scrollUp(); //移动动画
}
if (ad.isRunning())
ad.stop();
else
ad.start();
}
});
mailLayout.addView(lv);
}
int _screenHeight = 0;
int _screenWidth =0;
private void scrollUp() {
TranslateAnimation scrollUp = new TranslateAnimation(0, 0, _screenHeight, _screenHeight- lv.getMeasuredHeight());
scrollUp.setDuration(2500);
scrollUp.setFillEnabled(true);
scrollUp.setAnimationListener(
new AnimationListener() {
public void onAnimationStart(Animation animation) {
lv.setVisibility(View.VISIBLE);
}
public void onAnimationRepeat(Animation animation) {}
public void onAnimationEnd(Animation animation) {
//这四个点都是相对于左上的
lv.layout(0, _screenHeight- lv.getMeasuredHeight(), _screenWidth, _screenHeight);
}
}
);
lv.startAnimation(scrollUp);
}
private void scrolldown() {
TranslateAnimation scrollUp = new TranslateAnimation(0, 0, 0, _screenHeight );
scrollUp.setDuration(2500);
scrollUp.setFillEnabled(true);
scrollUp.setAnimationListener(
new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {}
public void onAnimationEnd(Animation animation) {
lv.setVisibility(View.GONE);
}
}
);
lv.startAnimation(scrollUp);
}
}
- 移动动画 移动之后停留在那里
- 移动动画
- PL/pgSQL检索移动轨迹停留区域
- Android 移动动画- TranslateAnimation
- Android 移动动画- TranslateAnimation
- QML-动画-移动字符串
- UIView动画移动效果
- 移动动画问题
- 简单移动动画
- iOS触摸移动动画
- 【动画】TranslateAnimation 移动控件
- TranslateAnimation移动动画Demo
- 足球移动动画
- css3移动端动画
- TranslateAnimation 动画移动
- html移动动画
- 属性动画的移动
- android动画-移动动画问题
- 要做好性能测试,该掌握些什么?
- archlinux滚动升级失败解决方法
- CSS引入的方式link和@import的区别
- 【开源项目】花密(Flower Password)VB版之遨游浏览器模块
- sybase执行存储过程的方法
- 移动动画 移动之后停留在那里
- 【开源项目】花密(Flower Password)VB版之模拟按键模块
- Android程序完全退出的三种方法
- getLatitudeSpan()
- 中国PC浏览器市场,尽是垃圾
- android 获取屏幕方向详解
- android 如何调用系统自带的程序安装器安装程序
- 足球比赛分析小软件
- 【开源项目】花密(Flower Password)VB版之INI文件读写模块