Splash Screen is resizing when switching to Main Activity

久未见 提交于 2020-08-08 10:47:46

问题


im currently working on an xamarin.forms application, which then will get shipped to android and ios.

In the end it is just an in app browser implementation of our website, so that cookie handling for our customers is secured.

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.

But see for yourself:

The Application has right now 2 Activities.

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));            
    }
}
  1. Main Activity
[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... */
}
  1. My Styles.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.

Thanks in Advance

* Update *

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>

回答1:


It looks like the Developer instrumentation is the cause for the flicker When i disabled it, it won't appear anymore.

How to disable the Developer Instrumentation: (VS 2019)




回答2:


I couldn't find the setting that @Isparia pointed out, so I tried running it in production mode. It appears that this issue does not happen in production mode, only in development. So I don't have to worry about this issue showing up for my users, even though I was seeing it in development.



来源:https://stackoverflow.com/questions/59103310/splash-screen-is-resizing-when-switching-to-main-activity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!