android - 当我隐藏 ProgressBar 时动画不再工作

标签 android animation progress-bar

长期听众,第一次来电...

我正在创建一个从名为 SplashBase 的 Activity 派生的闪屏,它被放置在一个共享项目中。布局如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/linlytSplash"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
>
   <ImageView
      android:id="@+id/imgvwSplash"
      android:src="@drawable/splashscreen"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
   ></ImageView>

   <LinearLayout
      android:id="@+id/linlytProgress"
      android:orientation="horizontal"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:layout_gravity="center"
      android:gravity="center"
   >
      <ProgressBar
         android:id="@+id/progbarProgress"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginRight="5dp"
      ></ProgressBar>
      <TextView
         android:id="@+id/txtvwProgress"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginLeft="10dip"
         android:gravity="center_vertical"
         android:text="@string/loading_ellipsis"
         android:textStyle="bold"
      ></TextView>

   </LinearLayout>

</LinearLayout>

我正在加载这样的动画:

  Animation animation = AnimationUtils.loadAnimation(this, R.anim.splashscreen_anim);
  animation.setAnimationListener(new AnimationListener() {
     public void onAnimationEnd(Animation animation) {
        // Advance to the next screen.
        if (null != m_intentToLaunch) {
           startActivity(m_intentToLaunch);
        }

        finish();
     }
  });

  animation.setStartTime(AnimationUtils.currentAnimationTimeMillis() + 1000);

我有一个名为 Splash 的派生类,它存在于我的主项目中。

我已经有这个闪屏很长时间了,动画一直有效。我的 ImageView 显示 2 秒,然后在调用 finish() 并加载下一个 Activity 之前动画并消失。

我现在添加了一个仅在第一秒显示的 ProgressBar(不完全是,但如果我这样解释它会更清楚)。出于某种原因,在我隐藏 ProgressBar 之后,动画不再适用于 ImageView。当我打电话时

findViewById(R.id.linlytProgress).setVisibility(View.INVISIBLE);

动画不再有效。为了进行测试,我调用了以下电话:

findViewById(R.id.txtvwProgress).setVisibility(View.INVISIBLE);

然后

findViewById(R.id.progbarProgress).setVisibility(View.INVISIBLE);

当我只隐藏 TextView 时,一切都按预期进行。当我隐藏 ProgressBar 时,砰的一声,我的 ImageView 不再有动画。我很茫然。

最佳答案

对我来说听起来像是一个错误。创建一个重现错误的示例项目,并在 http://b.android.com 上提交该示例项目的错误。 .请务必在您看到此问题的错误中提及(特定硬件或模拟器版本)。如果您想到它,请为此答案添加评论,并附上指向错误报告的链接。

关于android - 当我隐藏 ProgressBar 时动画不再工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6102806/

相关文章:

android - 如何在android中停止intentservice?

java - Android 多点触控图像查看延迟

java - Android(Java) 从 Netty Nio 服务器读取时套接字读取挂起

animation - CSS3 动画 : Why doesn't animating the same property work?

ios - 在 iOS 中创建动画进度条

android - 蓝牙 ACTION_FOUND broadcastReceiver 不工作

python - 如何获取利萨如曲线表中所有曲线的X和Y位置?

jquery - 用于文本颜色和移动文本的 css 动画,带有 jquery 示例

Python 进度条显示额外的百分比

c# - 为什么WPF中的BackgroundWorker需要Thread.Sleep来更新UI控件?