我正在制作一个带有闪屏的天气应用程序。
当我启动应用程序时,我启动了我拥有的ViewPager,之后,在ViewPager中,我立即启动了SplashScreen。在我收到天气信息之前,闪屏保持不动。之后,我在启动画面中的元素以及视图中的主LinearLayout容器上应用了slide_out动画。
我这样做是因为我希望在启动画面上实现平滑的幻灯片动画,就像它离开屏幕一样,通过手机底部,平滑地显示背后的主ViewPager。
问题是我可以看到主要的LinearLayout容器向下滑动,但它留下了半透明的屏幕,直到我在SplashScreen活动上调用完成。
任何人都可以帮我吗?
这是SplashScreen:
以下是SplashScreen动画:
这是动画结束后的SplashScreen:
直到我在SplashScreen上调用finish()时才会这样。我想慢慢揭示开始的活动。
SplashScreenActivity.java:
public class SplashScreenActivity extends AppCompatActivity {
@Bind(R.id.image)
ImageView imageView;
@Bind(R.id.textView)
TextView textView;
@Bind(R.id.container)
LinearLayout container;
RotateAnimation rotateAnim;
BroadcastReceiver releaseAnimationReceiver;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
ButterKnife.bind(this);
releaseAnimationReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.hasExtra("releaseAnimation")) {
Log.e("Splash", "receivedBroadcast");
//rotate(180);
rotateAnim = new RotateAnimation(0.0f, 180,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
rotateAnim.setDuration(500);
rotateAnim.setFillAfter(true);
rotateAnim.setFillEnabled(true);
rotateAnim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
imageView.setRotation(180);
Animation slideAnimation = AnimationUtils.loadAnimation(SplashScreenActivity.this, R.anim.slide_out);
slideAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
finish();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
textView.startAnimation(slideAnimation);
imageView.startAnimation(slideAnimation);
container.startAnimation(slideAnimation);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
imageView.startAnimation(rotateAnim);
//rotateAnim.start();
}
}
};
this.registerReceiver(releaseAnimationReceiver, new IntentFilter("com.iancuio.weathy"));
}
private void rotate(float degree) {
//rotateAnim.start();
}
@Override
protected void onDestroy() {
super.onDestroy();
this.unregisterReceiver(releaseAnimationReceiver);
}
}
SplashScreenActivity.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:id="@+id/container"
android:orientation="vertical"
android:gravity="center"
tools:context="com.iancuio.weathy.ui.splash.SplashScreenActivity">
<ImageView
android:layout_width="140dp"
android:src="@drawable/logo"
android:adjustViewBounds="true"
android:id="@+id/image"
android:layout_height="150dp" />
<TextView
android:layout_width="wrap_content"
android:text="TEXT"
android:id="@+id/textView"
android:layout_marginTop="10dp"
android:textColor="#000000"
android:layout_height="wrap_content" />
</LinearLayout>
slide_out.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillEnabled="true"
android:fillAfter="true">
<translate
android:duration="1000"
android:fromYDelta="0%p"
android:toYDelta="100%p" />
</set>