popWindow

 private void showPopWindow(View view) {
        long time = 1000;
        // 模糊动画  
        AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
        alphaAnimation.setDuration(time);
        alphaAnimation.setFillAfter(true);
        // 缩放动画  
        ScaleAnimation scaleAnimation = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setDuration(time);
        scaleAnimation.setFillAfter(true);
        // 动画集合  
        AnimationSet animationSet = new AnimationSet(true);
        animationSet.addAnimation(scaleAnimation);
        animationSet.addAnimation(alphaAnimation);
        //下面是popWindow的部分
        // 找到布局文件
        View v = View.inflate(getContext(),
                R.layout.popup_window_app_mannager, null);
        PopupWindow popupWindow;
        popupWindow = new PopupWindow(v,
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT, true);
        popupWindow.setBackgroundDrawable(new ColorDrawable());
        popupWindow.showAsDropDown(view, 100, -view.getHeight());
        // 开始动画
        v.setAnimation(animationSet);


    }

分开的

    private PopupWindow mPopupFirst; 

private void initPopWindow_First() {
        // 找到布局文件
        View v = View.inflate(getContext(),
                R.layout.view_see_or_change_iv_user, null);
        mTv_changephoto = v.findViewById(R.id.tv_changephoto);
        mTv_show_big = v.findViewById(R.id.tv_show_big);
        mTv_dissmis = v.findViewById(R.id.tv_dissmis);
        mPopupFirst = new PopupWindow(v,
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT, true);
        mPopupFirst.getContentView().measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        mPopupFirst.setBackgroundDrawable(new ColorDrawable());
        mPopupFirst.setAnimationStyle(R.style.Popupwindow_setPhoto);


    }

    private void ShowPopupWindow_First(View view) {

        mPopupFirst.showAsDropDown(view, view.getWidth() / 2 - mPopupFirst.getContentView().getMeasuredWidth() / 2, -view.getHeight() / 2 - 400);
        // 开始动画
        backgroundAlpha(0.5f);
        mPopupFirst.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                backgroundAlpha(1f);
            }
        });

    }



   public void backgroundAlpha(float bgAlpha) {
        WindowManager.LayoutParams lp = getActivity().getWindow().getAttributes();
        lp.alpha = bgAlpha; //0.0-1.0
        getActivity().getWindow().setAttributes(lp);
        getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    }

 背景

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- 圆角半径 -->
    <corners android:radius="20dp" />
    <!-- 背景颜色 -->
    <solid android:color="#eeeeeeee" />

</shape>

style

<style name="my_popwindow">
        <item name="android:windowEnterAnimation">@anim/pop_in</item>
        <item name="android:windowExitAnimation">@anim/pop_out</item>
    </style>

进入动画

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="500"
        android:fromYDelta="100%p"
        android:toYDelta="0" />
    <alpha
        android:duration="500"
        android:fromAlpha="0.0"
        android:toAlpha="1.0" />
</set>

退出动画

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="500"
        android:fromYDelta="0"
        android:toYDelta="100%p" />
    <alpha
        android:duration="500"
        android:fromAlpha="1.0"
        android:toAlpha="0.0" />
</set>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值