如何解决隐藏ProgressBar时动画不再起作用
| 长时间的聆听者,第一次的呼叫者... 我正在创建一个从Activity派生的初始屏幕,称为SplashBase,该屏幕放置在共享项目中。布局如下:<?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上向该示例项目提交错误。请务必在您看到此错误的地方提及(特定的硬件或仿真器版本)。如果您认为有问题,请在此答案中添加注释,并提供指向错误报告的链接。
,我终于找到了自己的问题的答案。该视图需要无效。
findViewById(R.id.imgvwSplash).invalidate();
等等!到目前为止,它完全可以按预期运行,并且可以在我尝试过的每个平台上使用。
感谢所有看过这个问题的人。
-I_Artist
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。