带旋转箭头的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;
}
});
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;
}
});
相关文章推荐
- Popuwindow点击外部控件切换popuwindow——解决点击外部事件不响应问题。
- Android PopupWindow响应外部控件点击事件
- ListView中item点事件和item中的控件点击事件冲突的简易解决方法
- 做项目过程中遇到的问题及解决----UIGesture手势与UI控件点击的事件冲突解决
- Android ListView的Item点击事件和Item里控件点击事件冲突问题解决
- ListView的点击事件与子控件点击冲突的解决
- popwindow弹出后点击外部控件响应点击事件
- Android:ListView的点击事件与子控件点击冲突的解决
- listview或gridview中item的点击事件与控件点击事件冲突的解决
- 解决Listview的item和里面控件点击事件冲突
- popwindow,弹出框,popwindow点击事件冲突问题很好的解决
- 解决Listview中Item中控件设置点击事件而Item点击事件失效问题
- 非模态的titlewindow,点击外部时的事件
- 控件点击事件会穿透给下面的界面--解决办法
- 一个简单的PopupWindow做的选项菜单点击按钮会在按钮下弹出几个下拉控件
- SlidingMenu+ViewPage+ListView嵌套(类似网易 ) ListView点击事件失效冲突问题解决
- 解决android listview中OnItemClickListener事件和里面button点击事件冲突问题
- 解决ViewFlow在Scrollview下滑动不灵敏的BUG(解决viewflow与父控件的滑动事件冲突问题)
- 解决触控点击事件和手势的冲突
- 关于ListView中控件点击事件与Item点击事件冲突的问题