安卓 高斯背景模糊popupwindow,弹簧弹出 rebounds

最终类似效果图,没有截动画,gridelayout弹上来的时候是波纹的。



直接上代码。

public class MyBlurPopWin extends BlurPopupWindow
{
    Context mContext;
    GridLayout gridLayout;
    SpringChain springChain;
    Button closeBtn;
    public MyBlurPopWin(Context context) {
        super(context);
        mContext=context;
    }


    @Override//父类回调,父类创建一个根FrameLayout,这里用来添加里面的内容。
    public void onCreatView(FrameLayout container) {
        //初始化很多东西,父类。
        super.onCreatView(container);
        //这里必须用三个参数,并且设置成false才能获得到layoutparams!!!否则获得到空的。
        //当然也可以自己设置layoutparams。
        View rootView = LayoutInflater.from(mContext).inflate(R.layout.layout,container,false);
        FrameLayout.LayoutParams frameLayout= (FrameLayout.LayoutParams) rootView.getLayoutParams();
        frameLayout.gravity=Gravity.BOTTOM;
        //rootView.findViewById(R.id.btn).setOnClickListener(this);
        //FrameLayout.LayoutParams layoutParams=new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        //layoutParams.gravity=Gravity.BOTTOM;
        //rootView.setLayoutParams(layoutParams);
        //找到id,view
        gridLayout = (GridLayout) rootView.findViewById(R.id.group);
        closeBtn= (Button) rootView.findViewById(R.id.btn);
        //设置监听,用来关闭popwin,用到了父类的backpress。
        setClickableItems(closeBtn);
        //添加到父容器。
        container.addView(rootView);
    }

    @Override//show的时候父类动画的时候调用此函数,在这里重写,实现自己需要的函数
    public void onShowAnimStart() {
        Log.e("xxx","onShowAnimStart");
        super.onShowAnimStart();
        springChain =SpringChain.create(50,6,40,7);             //faceBook的rebounds
        for (int i=0;i<gridLayout.getChildCount();i++){
            final View child=gridLayout.getChildAt(i);
            springChain.addSpring(new SimpleSpringListener(){
                @Override
                public void onSpringUpdate(Spring spring) {
                    super.onSpringUpdate(spring);
                    double value=spring.getCurrentValue();
                    child.setTranslationY((float) (value*gridLayout.getMeasuredHeight()));
                }
            });
        }
        for(Spring s:springChain.getAllSprings()){
            s.setCurrentValue(1);
        }

        springChain.setControlSpringIndex(1).getControlSpring().setEndValue(0);
    }

    @Override
    public vo
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值