其他分享
首页 > 其他分享> > android-ViewAnimationUtils无法正常工作

android-ViewAnimationUtils无法正常工作

作者:互联网

正在尝试实施以下代码段. [from developer documentation here]

 View myView = findViewById(R.id.my_view);

// get the center for the clipping circle
int cx = (myView.getLeft() + myView.getRight()) / 2;
int cy = (myView.getTop() + myView.getBottom()) / 2;

// get the final radius for the clipping circle
int finalRadius = Math.max(myView.getWidth(), myView.getHeight());

// create the animator for this view (the start radius is zero)
Animator anim =
    ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);

// make the view visible and start the animation
myView.setVisibility(View.VISIBLE);
anim.start();

获取以下错误.为什么会这样,我该如何解决.

java.lang.NoClassDefFoundError: android.view.ViewAnimationUtils
            at dejavu.appzonegroup.com.dejavuandroid.Fragment.PeopleTabFragment$1.onItemClick(PeopleTabFragment.java:59)
            at android.widget.AdapterView.performItemClick(AdapterView.java:299)
            at android.widget.AbsListView.performItemClick(AbsListView.java:1152)

解决方法:

ViewAnimationUtils是在API级别21(Lollipop 5.0)中添加的.您是否正在Lollipop上测试您的应用?它不适用于较旧的API级别.要使用它,您需要将min SDK设置为21.

标签:material-design,android
来源: https://codeday.me/bug/20191120/2042943.html