我有一个简单的动画。只有在单击时才会消失edittext,然后打开一个活动。 但是通过单击edittext它不会消失。当我回到edittext所在的活动时,动画正在发生。 我的错误在哪里?
动画:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_shortAnimTime">
<translate
android:fromYDelta="0%"
android:toYDelta="-100%"/>
<alpha
android:fromAlpha="1"
android:toAlpha="0"/>
</set>
活动代码:
editText1 = (EditText) findViewById(R.id.edt_1);
editText1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animation animationSet = AnimationUtils.loadAnimation(getContext(), R.anim.slideoutedittext);
editText1.setAnimation(animationSet);
animationSet.setDuration(500);
intent = new Intent(MainActivity.this, TestActivity.class);
startActivityForResult(intent, REQUEST_CODE_1);
overridePendingTransition(R.anim.fade_in,R.anim.fade_out);
}
});
答案 0 :(得分:0)
设置动画后立即放置View.GONE
:
editText1 = (EditText) findViewById(R.id.edt_1);
editText1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animation animationSet = AnimationUtils.loadAnimation(getContext(), R.anim.slideoutedittext);
editText1.setAnimation(animationSet);
animationSet.setDuration(500);
editText1.setVisibility(View.GONE);
intent = new Intent(MainActivity.this, TestActivity.class);
startActivityForResult(intent, REQUEST_CODE_1);
overridePendingTransition(R.anim.fade_in,R.anim.fade_out);
}
});