gpt4 book ai didi

android - 启动画面出现在android之前的黑屏

转载 作者:IT老高 更新时间:2023-10-28 21:56:41 27 4
gpt4 key购买 nike

我们知道,当应用程序执行一些较长的过程(例如从互联网下载一些信息)时,它可能会在加载应用程序之前显示启动画面,并且当应用程序完全加载时,它将显示主页。在启动屏幕 Activity 中,我们必须在线程中加载长进程以避免在加载应用程序之前显示黑屏。我已经完成了所有这些。但在显示应用程序之前也会出现黑屏。这是我的启动屏幕 Activity 的 onCreate 方法:

    protected override void OnCreate (Bundle bundle)
{
try {
base.OnCreate (bundle);
//_dt = DateTime.Now.AddSeconds (_splashTime);
SetContentView (Resource.Layout.Splash );
FirstLoadPB= FindViewById <ProgressBar >(Resource .Id.FirstLoadPB );
FirstLoadingInfo= FindViewById <TextView >(Resource .Id.FirstLoadInfo );
LoadApplication ();

} catch (System.Exception ex) {

Common.HandleException (ex);
}
}

这是LoadApplication方法的代码:

public void LoadApplication()
{
new System.Threading.Thread (new ThreadStart (() =>
{
//Some Codes to load applications- Downloading from web and accessing the storage(Because was many codes - about 100 line- i was clear them.

}
)
).Start ();
}

我不明白为什么会出现黑屏以及现在应该如何避免这种情况。我有一些代码可以访问我的应用程序类的 oncreate 中的存储。也许问题的根本原因来自那里。因此我分享了它的代码:

public override void OnCreate ()
{
try {
base.OnCreate ();
_typeOfShow = new MapViewType ();
ListingTypes = new Dictionary<int,ListingTypeItem> ();

OfflineMode =false;
PropertyShowWasShown = false;
MeasutingUnitsChanged =false;
if(RplXmlSettings .Instance .getVal (AppConstants .XmlSettingShowOnCurrentLocationKey )== "True")
typeOfShow .ShowOnCurrentLocation =true ;
else
typeOfShow .ShowOnCurrentLocation =false;
//StorageClass .ctx = ApplicationContext ;
FillDashboardOnResume =false;
//initlize image loader
ImageLoader = Com.Nostra13.Universalimageloader.Core.ImageLoader.Instance;
Options = new DisplayImageOptions.Builder ()
.ShowImageForEmptyUri (Resource.Drawable.ic_tab_map)
.CacheOnDisc ()
.CacheInMemory ()
.ImageScaleType (ImageScaleType.InSampleInt)
.BitmapConfig (Bitmap.Config.Rgb565)
.Displayer (new FadeInBitmapDisplayer (300))
.Build ();
ImageLoaderConfiguration config;

ImageLoaderConfiguration .Builder builder =new ImageLoaderConfiguration
.Builder (ApplicationContext).ThreadPoolSize (3);

if(RplXmlSettings .Instance .getVal (AppConstants .XmlSettingMemoryCacheKey )== "True")
builder .ThreadPriority (4).MemoryCacheSize (1500000) ;// 1.5 Mb

builder .
DenyCacheImageMultipleSizesInMemory ().
DiscCacheFileNameGenerator (new Md5FileNameGenerator ()).
MemoryCache (new WeakMemoryCache()).
DiscCacheSize (15000000);
config = builder .Build ();
ImageLoader.Init (config);

} catch (Exception ex) {
Common .HandleException (ex);
}

}

好的。长话短说。现在的问题是——这个黑屏的根本原因是什么。这是来自启动 Activity 还是来自应用程序类。以及我们如何解决它并避免表单显示此问题?

最佳答案

在 list 文件中的应用程序标签中添加一个带有您正在使用的背景的主题,以防止出现黑屏。

主题.xml

<resources>
<!-- Base application theme is the default theme. -->
<style name="Theme" parent="android:style/Theme" />

<style name="Theme.MyAppTheme" parent="Theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@drawable/my_app_background</item>

</style>
</resources>

AndroidManifest.xml

....
<application
android:name="@string/app_name"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MyAppTheme"
>
....

Read why there is a black screen here On app launch, Android displays a simple preview window (based on your activity theme) as an immediate response to the user action. Then the preview window crossfades with your actual UI, once that has fully loaded. To ensure a smooth visual transition, your activity theme should match your full UI as closely as possible. The below image shows how the experience can be jarring if not handled properly.

关于android - 启动画面出现在android之前的黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14307126/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com