Reputation: 712
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));
}
}
[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 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>
Upvotes: 3
Views: 1587
Reputation: 380
You should try the solution as explained here: https://stackoverflow.com/a/68343569/9210028
Basically, just set the application theme in the android project to the splash screen theme.
Upvotes: 0
Reputation: 376
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.
Upvotes: 0
Reputation: 712
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)
Upvotes: 3