安卓高级 特效动画ExplosionField和 SmoothTransition

本文介绍了一种名为SmoothTransition的UI动画实现方式,并提供了详细的使用指南。包括如何在Activity、ListView及Fragment中应用动画,以及一个具体的登录界面示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本教程所有图片为github上的所无法正常访问请***

SmoothTransition

展示效果
这里写图片描述

这里写图片描述

这里写图片描述

github:源码地址

使用方法

你能通过一行代码使用上面所有的动画

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    new SwitchAnimationUtil().startAnimation(getWindow().getDecorView(), Constant.mType);
}

如果你希望动画使用在 ListView / GridView 或者其他的 AdapterView可以按照如下方法:

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (mSwitchAnimationUtil == null) {
        mSwitchAnimationUtil = new SwitchAnimationUtil();
        mSwitchAnimationUtil.startAnimation(mList, Constant.mType);
    }
}

如果你想在Fragment使用动画:

class DemoFragment extends Fragment { private View mConverView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle     savedInstanceState) {
    mConverView = LayoutInflater.from(getActivity()).inflate(R.layout.view_fragment, null);
    mConverView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            new SwitchAnimationUtil().startAnimation(mConverView, Constant.mType);
        }
    });

    return mConverView;
}
}

你能添加依赖到你项目中使用

ExplosionField

git地址:项目源码

效果:
这里写图片描述

使用方法:带入依赖后

ExplosionField mExplosionField = ExplosionField.attach2Window(Context);
   mExplosionField.explode(view);

附送一个国内作者使用此效果做的登陆界面

转载于:https://www.cnblogs.com/muyuge/p/6152120.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值