im目前正在使用xamarin.forms应用程序,然后将其发送到android和ios。
最后,这只是我们网站的应用内浏览器实现,因此可以确保为我们的客户提供cookie处理。
现在的主要问题是,切换到主要活动时,初始屏幕会进行调整大小,至少看起来是这样,这在配备android 9.0的Android仿真器中不会发生,但是在配备android 10的像素2中不会发生。
但是自己看看:
该应用程序目前有2个活动。
1。飞溅活动
[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>
任何想法,为什么会发生这种情况以及如何防止这种情况。
预先感谢
*更新*
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>