问题描述
我目前正在开发一个 xamarin.forms 应用程序,然后该应用程序将发布到 android 和 ios.
im currently working on an xamarin.forms application, which then will get shipped to android and ios.
最终它只是我们网站的应用内浏览器实现,因此我们客户的 cookie 处理是安全的.
In the end it is just an in app browser implementation of our website, so that cookie handling for our customers is secured.
现在的主要问题是,当切换到主要活动时,启动画面会调整大小,至少看起来是这样,这不会发生在带有 android 9.0 的 Android 模拟器中,但在我的带有 android 10 的像素 2 上.
Main Problem right now is that the splashscreen does a resize when switching to the main activity, at least that's what it looks like, this doesn't happen in the Android Emulator with android 9.0, but on my pixel 2 with android 10.
但你自己看看:
应用程序现在有 2 个活动.
The Application has right now 2 Activities.
1.Splash Activity
1.Splash Activity
[Activity(Theme ="@style/Theme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
/*... shortend for readability ...*/
StartActivity(typeof(MainActivity));
}
}
- 主要活动
[Activity(Icon = "@drawable/icon", Theme = "@style/MainTheme.Base", MainLauncher = false)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
/* ... some more stuff... */
}
- 我的样式.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="Theme.Splash" parent="@android:style/Theme.NoTitleBar.Fullscreen">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowActionBar">true</item>
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="@android:style/Theme.NoTitleBar.Fullscreen">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from https://aka.ms/material-colors -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#2196F3</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1976D2</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#FF4081</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
</resources>
任何想法为什么会发生这种情况以及如何防止这种情况将不胜感激.
Any Ideas why this happens and how to prevent that would be appreciated.
提前致谢
* 更新 *
splash_screen.xml
splash_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="#fff"/>
</item>
<item>
<bitmap
android:src="@drawable/alwbg"
android:tileMode="disabled"
android:gravity="center"/>
</item>
</layer-list>
推荐答案
看起来像 Developer 检测是导致闪烁的原因当我禁用它时,它就不会再出现了.
It looks like the Developer instrumentation is the cause for the flickerWhen i disabled it, it won't appear anymore.
如何禁用开发人员工具:(VS 2019)
这篇关于切换到主活动时,启动画面正在调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!