我正在尝试在新活动开始时应用从右到左的动画,但每当我点击启动活动的TextView时,我的应用程序就会完全冻结,
这是我的动画文件:
输入:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="500"
android:fromXDelta="100%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>
退出:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="500"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="-100%"
android:toYDelta="0%" />
</set>
这是我的MainActivity.java:
public class MainActivity extends AppCompatActivity {
@BindView(R.id.input_email) EditText email;
@BindView(R.id.input_password) EditText password;
@BindView(R.id.login_button) AppCompatButton loginButton;
@BindView(R.id.signup_link_user) TextView signUp
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();
ButterKnife.bind(this);
signUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, SignUp.class);
startActivity(intent);
overridePendingTransition(R.anim.enter, R.anim.exit);
}
});
}
}
单击TextView时的事件日志:
05-24 04:14:41.800 1206-1230/? E/WindowManager: Unhandled exception while laying out windows
android.content.res.Resources$NotFoundException: Resource ID #0x7f050012
at android.content.res.Resources.getValue(Resources.java:1359)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2789)
at android.content.res.Resources.getAnimation(Resources.java:1197)
at android.view.animation.AnimationUtils.loadAnimation(AnimationUtils.java:75)
at com.android.server.wm.AppTransition.loadAnimationRes(AppTransition.java:449)
at com.android.server.wm.AppTransition.loadAnimation(AppTransition.java:1014)
at com.android.server.wm.WindowManagerService.applyAnimationLocked(WindowManagerService.java:3611)
at com.android.server.wm.WindowManagerService.setTokenVisibilityLocked(WindowManagerService.java:4733)
at com.android.server.wm.WindowManagerService.handleAppTransitionReadyLocked(WindowManagerService.java:9762)
at com.android.server.wm.WindowManagerService.performLayoutAndPlaceSurfacesLockedInner(WindowManagerService.java:10508)
at com.android.server.wm.WindowManagerService.performLayoutAndPlaceSurfacesLockedLoop(WindowManagerService.java:9310)
at com.android.server.wm.WindowManagerService.performLayoutAndPlaceSurfacesLocked(WindowManagerService.java:9257)
at com.android.server.wm.WindowManagerService.access$400(WindowManagerService.java:201)
at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:8117)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
我没有在styles.xml中更改任何内容
答案 0 :(得分:0)
再次检查是否将动画文件和integer.xml文件放在要测试的Android版本可访问的值文件夹中。
我犯了一个错误:仅在values-v29文件夹中拥有一个integer.xml文件,因此该项目得以编译并运行,但是该整数不适用于较低版本。