Issue
From the question Issue dismissing popup window I learned how to hide the popupWindow (before this, popupWindow.dismiss(); in the following code didn't work).
private void initFAB(){
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
boolean showPopupWindow = false;
public void onClick(View view) {
LayoutInflater layoutInflater = (LayoutInflater) getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupWindowContent = layoutInflater.inflate(R.layout.popup_window_content, null);
final PopupWindow popupWindow = new PopupWindow(popupWindowContent,
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setOutsideTouchable(true);
if (!showPopupWindow){
rotateFabForward();
View.OnClickListener onClickListener = new View.OnClickListener() {
public void onClick(View view) {
//...
}
};
// ...
popupWindow.showAtLocation(fab, Gravity.END | Gravity.BOTTOM, 50, 400);
showPopupWindow = true;
}
else{
rotateFabBackward();
popupWindow.dismiss();
showPopupWindow = false;
}
}
});
}
Now, when I click outside the popupWindow and it disappears, FloatingActionButton don't rotates back (it has + icon when the popupWindow is hidden and rotates 45 degress and icon becomes × when the popupWindow is visible).
Any listeners that allows to registry the touch outside the popupWindow and execute rotateFabBackward()?
P. S. Also, thanks for the answer on this question about FAB rotation.
Solution
you should add onDismiss listener like that
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
rotateFabBackward();
showPopupWindow = false;
// end may TODO anything else
}
});
Answered By - ToanNV
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.