开发者

Animation is not working in Emulater

i am enable to load animation in Emulater..Its working fine with any real device..

public开发者_StackOverflow class MainActivity extends Activity {

    private ImageView imgView;
    private Animation animation;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.grow);
        animation.setRepeatCount(50); // Repeat animation infinitely
        animation.setRepeatMode(Animation.REVERSE); 

        imgView = (ImageView) findViewById(R.id.imgView);
        imgView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub


                imgView.startAnimation(animation);      



                new Handler().postDelayed(new Runnable() {
                    public void run() {

                        Intent it = new Intent(getApplicationContext(), MyWebView.class);
                        startActivity(it);

                    }
                }, 5000);


            }
        });
    }

and my anim xml file is following

<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
            android:fromDegrees="0"
            android:toDegrees="360"
            android:pivotX="50%"
            android:pivotY="50%"
            android:duration="50" />


I think you Might have Disabled Animations in Emulator: Check that:

Settings>Display>Animation..

Hope that helps your Problem


For anyone running into similar issues when using ObjectAnimator, in my case I had to enable the developer settings on the emulator and then go into "Settings" > "Developer options" > "Drawing" section

In this "Drawing" section you'll find different options for each animation type, in my case the "Animator duration scale" was off, after setting it to "1x" I started seeing the animations on the emulator.


UI tests could disable animations on emulator or device and if you want them back you need to enable Developer options manually and turn them back on in Drawing section one by one.

Or maybe you can enable them back again by running ui tests while changing in your app module build.gradle :

android {
    ...
    testOptions {
       ...
       animationsDisabled = false
       ...
    }
    ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜