Note that there are some explanatory texts on larger screens.

plurals
  1. POSwitch text between EditTexts during TranslateAnimation
    primarykey
    data
    text
    <p>I have a vertically-oriented LinearLayout (inside a ScrollView) that holds dynamically created Views. Each of these Views contain an EditText. As an option, I would like the user to be able to reorder these Views. </p> <p>For the reordering, I am providing an UP and a DOWN button. This works great. The animation is smooth and gives the expected output.</p> <p><strong>Setup:</strong></p> <p>The animation is just a visual feedback: I am <em>NOT</em> reordering the Views. I'm only switching the data between two EditTexts. For example:</p> <pre><code>View1 ==== EditText1 ==== TextData1 View2 ==== EditText2 ==== TextData2 </code></pre> <p>When the animation ends:</p> <pre><code>View1 ==== EditText1 ==== TextData2 View2 ==== EditText2 ==== TextData1 </code></pre> <p><strong>The Problem:</strong></p> <p>I am currently switching the <code>EditText.getText().toString()</code> values in <code>onAnimationEnd(Animation)</code>. This isn't smooth at all. The best I can do to describe the effect: <code>flicker</code>. There's a flicker when the values are switched. </p> <p>Is there any way to avoid this? </p> <p><strong>TranslateAnimation:</strong></p> <pre><code>static TranslateAnimation translate(float fromX, float toX, float fromY, float toY, int ms) { TranslateAnimation transAnim = new TranslateAnimation(fromX, toX, fromY, toY); transAnim.setDuration(ms); return transAnim; } </code></pre> <p>How the animation is being applied:</p> <pre><code>// Animate viewToMove to move to viewToReplace's position TranslateAnimation ta = Utils.translate(0, 0, 0, -viewToReplace.getHeight(), 2000); // Animate viewToReplace to move to viewToMove's position TranslateAnimation ta2 = Utils.translate(0, 0, 0, viewToMove.getHeight(), 2000); // AnimationListener ta.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // Grab the text that is held by viewToMove's EditText String temp = ((EditText) (viewToMove.findViewById(R.id.etListItemText))).getText(). toString(); // Set viewToMove's EditText to show contents of viewToReplace's EditText ((EditText) (viewToMove.findViewById(R.id.etListItemText))). setText(((EditText) (viewToReplace. findViewById(R.id.etListItemText))). getText().toString()); // Set viewToReplace's EditText contents ((EditText) (viewToReplace.findViewById(R.id.etListItemText))). setText(temp); } }); // Start animations viewToMove.startAnimation(ta); viewToReplace.startAnimation(ta2); </code></pre>
    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.
    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