[将WindowSoftInputMode
设置为Android.Views.SoftInput.AdjustResize
后,我们在Android中遇到问题。当显示或隐藏键盘时,我们的启动屏幕会在键盘动画所在的位置上方闪烁。这是很烦人的。
这里是它的一个片段,您可以看到飞溅在后面窥视。
据我看来,这可能是问题所在。如果您在Styles.xml中设置SplashScreen,则如下所示:
<style name="MainTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splashscreen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
而且不只是将LoginActivity(登录屏幕)设置为MainLaucher,初始屏幕永远不会被丢弃,它将贯穿整个应用程序。想象一下,在启动屏幕上有更大的图像并将其拖过整个应用程序,过一会儿会导致内存泄漏。
如何解决。创建类似于中间件活动的内容,它将与初始屏幕相同,例如:
[Activity(Theme = "@style/MainTheme.Splash", MainLauncher = true, NoHistory = true, Icon = "@drawable/appicon")] public class SplashActivity : AppCompatActivity { public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState) { base.OnCreate(savedInstanceState, persistentState); } // Launches the startup task protected override void OnResume() { base.OnResume(); Task startupWork = new Task(() => { SimulateStartup(); }); startupWork.Start(); } // Simulates background work that happens behind the splash screen async void SimulateStartup() { await Task.Delay(500); // Simulate a bit of startup work. You can remove this StartActivity(typeof(LoginActivity)); // Your Activity } } }
不仅仅是使用全新的LoginActivity
[Activity(Label = "LoginActivity")]
public class LoginActivity : AppCompatActivity
{
}