【问题标题】:basic animation issue - can't find animate method基本动画问题 - 找不到动画方法
【发布时间】:2015-04-07 16:30:21
【问题描述】:

我正在阅读有关 Android 属性动画的内容,但被困在一楼。我有一个 ImageView(和一个 TextView),我正在尝试制作动画,但似乎没有“动画”方法。我键入 myImageView。并且有很多下拉方法,但没有动画方法。

我在 Eclipse 中使用 Java,并且我看到了其他代码示例。 这是我的 ImageView...

 <ImageView
    android:id="@+id/molePic"
    android:layout_width="36dip"
    android:layout_height="36dip"
    android:layout_marginTop="7dip"
    android:layout_marginLeft="20dip"
    android:src="@drawable/mutebeacon36x36" />           

【问题讨论】:

    标签: android animation


    【解决方案1】:

    View.animate() 方法已添加到 API 级别 12 (Android 3.1)。您正在针对哪个版本的 Android 进行编译?

    【讨论】:

    • 就是这样。我在 15 岁编译,它就在那里。谢谢
    【解决方案2】:

    这是一个示例动画方法。它将在 1000 毫秒内将视图向右平移 500 像素。

    public void startMyAnimation(final View view) {
    
        TranslateAnimation animation = new TranslateAnimation(0, 500, 0, 0);
        animation.setDuration(1000);
        view.startAnimation(animation);
    
        animation.setAnimationListener(new TranslateAnimation.AnimationListener() {
    
            @Override
            public void onAnimationStart(Animation animation) {
                isAnimating = true;
            }
    
            @Override
            public void onAnimationRepeat(Animation animation) {
            }
    
            @Override
            public void onAnimationEnd(Animation animation) {
    
             }
        });
    }
    

    你这样称呼它

    startMyAnimation(findViewById(R.id.molePic));
    

    【讨论】:

      猜你喜欢
      • 2015-11-20
      • 2015-02-06
      • 1970-01-01
      • 1970-01-01
      • 2011-08-07
      • 1970-01-01
      • 2019-05-31
      • 2018-11-12
      • 1970-01-01
      相关资源
      最近更新 更多