我想知道,如果我可以显示某种动画,直到我的活动加载。因为当我启动我的应用程序时,大约需要5秒钟才能看到活动。在加载之前,会显示一个白色屏幕(请参阅以下的图片)。我的活动加载之前是否可以显示动画?
我可以那样做吗?
如果可以,应该怎么做?
非常感谢您。 祝您有美好的一天。
我想知道,如果我可以显示某种动画,直到我的活动加载。因为当我启动我的应用程序时,大约需要5秒钟才能看到活动。在加载之前,会显示一个白色屏幕(请参阅以下的图片)。我的活动加载之前是否可以显示动画?
我可以那样做吗?
如果可以,应该怎么做?
非常感谢您。 祝您有美好的一天。
如果您下载一些数据,或者你长了ridiculusly大列表视图 - 你还有其他问题....
下载数据:减少所需要的应用程序工作
列表视图数据的大写金额 - 用户如果这是一个合法的问题 - 那么你需要某种类型的监听程序(表示任务完成时),比如Thread.join(),并且每当该监听程序激活时 - 它应该转到另一个意图并且最后一次杀死一个(杀死你需要使用finish();)
我初始化6个按钮并请求运行时权限。我认为请求权限可能会导致此问题。 – Freddie
如果权限正确实施 - 它不应该导致任何问题。 –
https://github.com/WithoutCaps/FileEditor/blob/master/app/src/main/java/site/withoutcaps/fileeditor/FileEditor.java其实有一些基本的(有点儿糟糕的)实现。时间你的一些方法,并试图找出它因为错误 –
我不知道你是否可以在那里放置一个动画,但是你可以使用带有你的应用徽标的闪屏或任何其他的背景。您花费在查看此初始屏幕上的时间恰好是应用程序自行配置所花费的时间。所以在任何设备上都没有区别。
在RES创建XML可绘制/可绘:
<item
android:drawable="@color/gray"/>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher"/>
</item>
导航到您的样式。 xml文件并为您的splash活动添加新主题。
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
创建闪屏的活动。无需为此活动设置视图。观点来自主题。当您在主题中为您的飞溅活动设置UI时,它立即可用。
public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = new Intent(this, MainActivity.class); startActivity(intent); finish(); } }
这个网站代码格式化有问题!有人请纠正。 –
尝试使用ProgressDialog
在AsyncTask
new YourFragment.YourAsyncTask().execute();
使用这个库sweet-alert-dialog更多的动画加载
class YourAsyncTask extends AsyncTask<Void, Void, Void> {
SweetAlertDialog pDialog;
@Override
protected void onPreExecute() {
//show your dialog here
super.onPreExecute();
pDialog = new SweetAlertDialog(getContext(), SweetAlertDialog.PROGRESS_TYPE);
pDialog.getProgressHelper().setBarColor(Color.parseColor("#fdc80b"));
pDialog.setTitleText("Loading...");
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected Void doInBackground(Void... params) {
return null;
}
@Override
protected void onPostExecute(Void result) {
//hide your dialog here
super.onPostExecute(result);
pDialog.dismissWithAnimation();
}
}
}
}
你可以显示进度对话框 - 加载动画5秒 – rafsanahmad007
但我不知道它是否持续5秒在所有设备上,或者只是我的 – Freddie