首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >弹幕处理/加载后移除

弹幕处理/加载后移除
EN

Stack Overflow用户
提问于 2017-11-08 13:03:25
回答 3查看 2.2K关注 0票数 6

我在我的xamarin android应用程序中启动了一个启动屏幕,所发生的情况是,splash屏幕一直作为背景出现在其他页面上。

不管我做什么它都在那里。

我一直试图“完成”活动,NoHistory=true,但什么都没有,一直在后台的其他页面上显示。

取自https://alexdunn.org/2017/02/07/creating-a-splash-page-for-xamarin-forms-android/

知道为什么吗?

代码语言:javascript
复制
      [Activity(Label = "MyApp",
    Theme = "@style/MyTheme.Splash",
    Icon = "@drawable/icon", 
    MainLauncher = true, 
    NoHistory = true,
    ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.tabs;
            ToolbarResource = Resource.Layout.toolbar;

            base.OnCreate(bundle);

            Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App(new AndroidInitializer()));      

        }
    }


     [Activity(
            Theme = "@style/MyTheme.Splash",
            MainLauncher = true,
            NoHistory = true,
            ScreenOrientation = ScreenOrientation.Portrait)]
        public class SplashActivity : AppCompatActivity
        {

            public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
            {
                base.OnCreate(savedInstanceState, persistentState);

            }


          protected override void OnResume()
         {
           base.OnResume();
             var startUp = new Task(() =>
            {
             var intent = new Intent(this, typeof(MainActivity));
            StartActivity(intent);
        });
    startUp.ContinueWith(t => Finish());

    startUp.Start();
    }

      <style name="MyTheme.Splash" parent ="Theme.AppCompat.Light">
        <item name="android:windowBackground">@drawable/splash_screen</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
      </style>
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-11-08 13:14:22

这是由Theme = "@style/MyTheme.Splash"引起的。这两种活动都使用相同的主题。

为其他活动创建一个不同的主题。

代码语言:javascript
复制
<style name="MyTheme.Main" parent ="Theme.AppCompat.Light">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

改变活动的主题:

代码语言:javascript
复制
[Activity(
    Theme = "@style/MyTheme.Main",
    MainLauncher = true,
    NoHistory = true,
    ScreenOrientation = ScreenOrientation.Portrait)]
public class SplashActivity : AppCompatActivity
{

    public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
    {
        base.OnCreate(savedInstanceState, persistentState);

    }
}
票数 5
EN

Stack Overflow用户

发布于 2017-11-08 15:06:18

另一种解决方案不是创建一个新的主题,而是在布局文件中为每个不是SplashScreen活动的活动中的父视图设置背景色。

票数 2
EN

Stack Overflow用户

发布于 2022-02-28 07:31:32

你的问题主要是由两个使用相同主题的活动引起的。

在"MainActivity“中,将主题从"@style/MyTheme.Splash”更改为"@style/MainTheme",这将使主活动使用默认主题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47180471

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档