【发布时间】:2016-02-03 15:23:13
【问题描述】:
当我启动我的应用程序时,出现片刻黑屏,然后只出现启动画面。我遵循了this 线程中的一些解决方案,但没有任何效果。它的实际原因可能是什么?谁能帮忙?我已经粘贴了下面的代码。
SplashScreenActivity.java
public class SplashScreenActivity extends Activity {
private static final int SPLASH_TIME_OUT = 3 * 1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash);
Util.doGuestLoginAndCheckForExpireDate();
UserDetail.deleteUserDetailJson();
Util.setProfileFetchStatus(false);
// Start animating the image
final ImageView splash = (ImageView) findViewById(R.id.logoImageViw);
final TranslateAnimation anim = new TranslateAnimation(0f, 0f, 1200f, 0f);
anim.setDuration(1200);
anim.setFillAfter(true);
splash.startAnimation(anim);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
splash.setAnimation(anim);
if (Util.getLoginStatus()) {
startActivity(new Intent(SplashScreenActivity.this, RestActivity.class));
} else
startActivity(new Intent(SplashScreenActivity.this, AppIntroduction.class));
finish();
}
}, SPLASH_TIME_OUT);
}
}
这是theme 我已包含在Application tag 内的Android manifest.xml 文件中
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/primary_color</item>
<item name="windowNoTitle">true</item>
<item name="colorAccent">@color/primary_color</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="android:windowContentOverlay">@null</item>
</style>
我在这里做错了吗??
【问题讨论】:
-
评论动画部分并查看
-
@MaheshwarLigade 做到了,但仍然是同样的问题。
-
检查ImageView初始化之前调用的方法可能是他们需要很长时间才能完成各自的任务
-
@JiteshDalsaniya 我尝试通过注释图像视图部分初始化上面的所有行来运行应用程序,但问题仍然存在
-
Runnable 的 run 方法中的代码将 ui 更新代码放入 runOnUIThread 方法中然后检查。
标签: android splash-screen