долгое время слушатель, впервые звонящий ...
Я создаю заставку, созданную на основе 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 () и загрузкой следующего действия.
Я сейчас добавляю 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 больше не анимируется. Я в растерянности.