界面切换动画

//设置图片宽度

private void InitImageView() {

// 只是改变宽度而已
cursor = (ImageView) findViewById(R.id.cursor);
int width = getWindowManager().getDefaultDisplay().getWidth();
width /= 3;
LinearLayout.LayoutParams params = (android.widget.LinearLayout.LayoutParams) cursor
.getLayoutParams();
params.width = width;
cursor.setLayoutParams(params);
}


      

//viewpager切换动画

private class OnPageChangeListener implements
android.support.v4.view.ViewPager.OnPageChangeListener {


@Override
public void onPageScrollStateChanged(int arg0) {
// TODO Auto-generated method stub


}


@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
// TODO Auto-generated method stub


}


@Override
public void onPageSelected(int arg0) {
Animation animation = null;
switch (arg0) {


case 0:
if (state == 1) {// 1---》0
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 1,
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0);


} else if (state == 2) {// 2---》0
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 2,
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0);


}


break;


case 1:
if (state == 0) {// 0---》1
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 1,
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0);
} else if (state == 2) {// 2---》1
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 2,
Animation.RELATIVE_TO_SELF, 1,
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0);


}


break;


case 2:


if (state == 0) {// 0---》2


animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 2,
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0);


} else if (state == 1) {// 1--》2
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 1,
Animation.RELATIVE_TO_SELF, 2,
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0);


}


break;


}


state = arg0;
animation.setFillAfter(true);// True:图片停在动画结束位置
animation.setDuration(300);


cursor.startAnimation(animation);


}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
各种炫酷页面切换效果,非常动感,有源代码,可以提供前端开发人员,UI设计人员丰富的创作灵感。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值