gpt4 book ai didi

android - 切换到主 Activity 时启动画面正在调整大小

转载 作者:行者123 更新时间:2023-11-29 02:17:52 26 4
gpt4 key购买 nike

我目前正在开发 xamarin.forms 应用程序,该应用程序随后将发布到 android 和 ios。

最后,它只是我们网站的应用程序浏览器实现,因此我们客户的 cookie 处理是安全的。

现在的主要问题是启动画面在切换到主要 Activity 时会调整大小,至少看起来是这样,这不会发生在 Android 9.0 的 Android Emulator 中,但在我的 Pixel 2 和 Android 10 上.

但是你自己看看:

Spash Screen Resizeing

应用程序现在有 2 个 Activity 。

1.飞溅 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. 主要 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. 我的 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>

任何想法为什么会发生这种情况以及如何防止这种情况将不胜感激。

提前致谢

* 更新 *

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 instrumentation 是闪烁的原因当我禁用它时,它不会再出现。

如何禁用 Developer Instrumentation:(对比 2019)

Disabling Developer instrumentation stops the flickering

关于android - 切换到主 Activity 时启动画面正在调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59103310/

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