gpt4 book ai didi

java - 动画后我无法清除我的 ImageView

转载 作者:行者123 更新时间:2023-11-29 23:13:48 25 4
gpt4 key购买 nike

我无法让图像消失或从 Activity 中清除它

启动器 Activity :-logo 是声明的 imageview

 Animation img = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fade);
logo.startAnimation(img);
if(logo.getImageAlpha()==0.1) {
logo.setImageDrawable(null);
}

fade.xml:-

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<alpha
android:duration="4000"
android:fromAlpha="1.0"
android:toAlpha="0.0"/>

</set>

我以为 ImageView 会被清除,但事实并非如此。我想要一些方法让 ImageView 在动画结束时消失

最佳答案

没有试过,但我认为它可能会起作用。试试这个:

Animation img = AnimationUtils.loadAnimation(context, R.anim.fade); //no need to use getApplicationContext I think
logo.startAnimation(img);

img.setAnimationListener(new Animation.AnimationListener(){
@Override
public void onAnimationStart(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
//try to clear the image here
logo.setImageDrawable(null);

//or you can make the imageview to invisible
logo.setVisibility(View.INVISIBLE);
}
});

关于java - 动画后我无法清除我的 ImageView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55646583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com