Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy setting visibility fails for Views with animation?
    primarykey
    data
    text
    <p>An <code>ImageView</code> is animated with a rotate animation :</p> <pre><code>import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.LinearInterpolator; import android.view.animation.RotateAnimation; import android.widget.ImageView; public class Test extends Activity implements View.OnClickListener { private ImageView mIcon; private Animation mRotate; private boolean mShown = true; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mIcon = new ImageView(this); mIcon.setImageDrawable( getResources().getDrawable(android.R.drawable.ic_dialog_alert) ); mIcon.setOnClickListener(this); setContentView(mIcon); mRotate = new RotateAnimation( 0f,360f, getWindowManager().getDefaultDisplay().getWidth()/2, getWindowManager().getDefaultDisplay().getHeight()/2 ); mRotate.setDuration(2000); mRotate.setRepeatMode(Animation.RESTART); mRotate.setRepeatCount(Animation.INFINITE); mRotate.setInterpolator(new LinearInterpolator()); mIcon.setAnimation(mRotate); } @Override public void onClick(View view) { if(mShown){ mRotate.cancel(); mIcon.setVisibility(View.GONE); }else { mIcon.setVisibility(View.VISIBLE); mRotate.reset(); mRotate.start(); } mShown = !mShown; } } </code></pre> <p>The part <code>mProgress.setVisibility(GONE);</code> doesn't work. The <code>ImageView</code> doesn't hides at all. If I don't set the <code>Animation</code> for it, it works well. </p> <p>My question is: <strong>why the animated view's visibility is not changing ?</strong></p> <p>UPDATE: Wrapping the View in a <code>FrameLayout</code> and setting <code>FrameLayout</code>'s visibilty works. But still, this is an ugly workaround.</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.
    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