• 手机版

    扫码体验手机版

  • 微信公众号

    扫码关注公众号

国内首家协议开发

软芯音视解码保护平台

在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

点击按钮,调用 AlphaAnimation 的 start 方法无效,什么原因?

public class MainActivity extends Activity {    private ImageView imageView;    private Button start, stop;    private AlphaAnimation animation;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        imageView = findViewById(R.id.gif);        start = findViewById(R.id.startAnimation);        stop = findViewById(R.id.stopAnimation);        animation = new AlphaAnimation(1.0f, 0.0f);        start.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                animation.setDuration(3000);                imageView.setAnimation(animation);                // animation.start();                animation.startNow();            }        });    }}点击按钮,动画无效,start 和 startNow 都不行,调用 View 的 startAnimation 却可以启动动画

但是,把按钮当中的内容直接写在 onCreate 方法当中,动画却可以启动,什么原因?
我知道直接调用 View.startAnimation 可以启动动画,就是想知道 start 和 startNow 为什么在按钮点击事件中不行?

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

发新帖

发布任务需求已有1031168位用户正在使用天盟网服务

发布分类: *
任务预算: *
需求内容: *
手机号码: *
任务商家报价为
  • 预算价 :
  • 成交价 :
  • 完工期 :
  • 质保期 :

* 最终任务项目以服务商报价、双方协商为准!