【问题标题】:Use progress bar as Image View src?使用进度条作为 Image View src?
【发布时间】:2014-09-12 08:36:14
【问题描述】:

是否可以将旋转进度条用作 Android XML 中 Image View 的 src?或者如果不通过 XML 则以编程方式进行?

提前谢谢你。

【问题讨论】:

    标签: android xml imageview


    【解决方案1】:

    使用AnimationDrawable 在图像视图中显示进度

    ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);
    img.setResource(R.drawable.spin_animation);
    
    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable frameAnimation = (AnimationDrawable) img.getDrawable();
    
    // Start the animation (looped playback by default).
    frameAnimation.start();
    

    有关帧动画 android 的详细信息,请参阅this。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-07
      • 1970-01-01
      • 2020-07-17
      • 1970-01-01
      相关资源
      最近更新 更多