您的位置:首页 > 运维架构

带旋转箭头的popupWindow的外部点击事件和控件点击事件冲突解决

2017-02-16 10:41 363 查看
1.图标旋转的开启和复位

iv.animate().setDuration(500).rotation(180).start();

iv.animate().setDuration(500).rotation(0).start();//旋转0度是复位

2.设置popupwindow

      //设置可以获得焦点        

       setFocusable(true);   

    //设置弹窗内可点击       

      setTouchable(true);

   //设置弹窗外可点击 

       setOutsideTouchable(true);

        setOnDismissListener(new PopupWindow.OnDismissListener() {//监听OnDisMissListener统一消失的时候让箭头重置

            @Override

            public void onDismiss() {

                iv.animate().setDuration(500).rotation(0).start();

            }

        });

/**----------------设置点击弹窗外让popwindow消失,会导致iv的点击事件冲突----------------**/

解决方案:监听OnTouchListener拦截事件
        setTouchInterceptor(new View.OnTouchListener() {

            @Override

            public boolean onTouch(View v, MotionEvent event) {

                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {

                   dismiss();

                    return true;

                }

                return false;

            }

        });
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐