Note that there are some explanatory texts on larger screens.

plurals
  1. PONext & Previous Animations
    primarykey
    data
    text
    <p>I have made a <code>PopupWindow</code> that pops up when a user selects an item in a list. And then when he swipes left and right on the popup window, the data (in the popup) is change to the previous and next items in the list, respectively.</p> <p>And I have made it so that it looks like a new popup window is sliding in from the left as the current one goes out from the right of the screen when the user slides his finger to the right ("Next" motion). And vice versa for the "Previous" motion.</p> <p>But the issue is, as I have made 2 styles for the two animations (left-to-middle while middle-to-right and right-to-middle while middle-to-left), and as <code>PopupWindow</code>s does not get updated while it is showing, when the user swipes to the right ("Next") and then to the left ("Previous"), the animation looks choppy as the 2 animations overlap. The same happens when the swipes are reversed again.</p> <p>Now, if I call <code>update()</code> after changing the Animation, then it again slides in to the middle. That's even worse. So is there anything I can do to achieve the behavior I want?</p> <p>Thanks.</p> <p><strong>EDIT: Source Code</strong></p> <p>Here is the code I used to show the popup for the first time:</p> <pre><code>popup1 = new PopupWindow(popupLayout, popup_width, popup_height, true); popup1.setAnimationStyle(R.style.AnimationPopup); popup1.showAtLocation(this.findViewById(R.id.main_container), Gravity.CENTER, 0, 0); </code></pre> <p>And this is the <code>next()</code> method's code:</p> <pre><code>if(popup2 != null) popup1 = popup2; if(popup1 != null) { popup2 = new PopupWindow(popupLayout, popup_width, popup_height, true); popup2.setAnimationStyle(R.style.AnimationPopup); popup1.dismiss(); popup2.showAtLocation(rootLayout, Gravity.CENTER, 0, 0); } </code></pre> <p>And this is the <code>prev()</code> method's code:</p> <pre><code>if(popup2 != null) popup1 = popup2; if(popup1 != null) { popup2 = new PopupWindow(popupLayout, popup_width, popup_height, true); popup2.setAnimationStyle(R.style.AnimationPopupReverse); popup1.setAnimationStyle(R.style.AnimationPopupReverse); popup1.dismiss(); popup2.showAtLocation(rootLayout, Gravity.CENTER, 0, 0); } </code></pre> <p>That's all for the Java code. The <code>AnimationPopup</code> is a XML with a simple <em>show</em> of slide-from-right-to-center and a <em>hide</em> of slide-from-center-to-left animations. And the <code>AnimationPopupReverse</code> is the reverse of the above animations.</p> <p>I have provided my first try of the codes. Here, the changed animations take effect <em>after</em> one more popup has been shown.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload