1

我在这里按照 Xamarin 的说明进行操作:http: //docs.xamarin.com/android/tutorials/Creating_a_Splash_Screen

这很好用,但根本没有提到横向模式。我可以将我的初始图像旋转为纵向大小,以获得最佳效果,但它仍然不理想:初始图像随着它的消失和主要活动的启动而旋转。这是因为启动活动是纵向模式,而主要活动是横向模式。

我尝试将“screenOrientation = ScreenOrientation.Landscape”添加到启动活动的 Activity 属性,但这会导致启动屏幕不显示。

根据这个问题,不可能禁用旋转动画,所以我真的很想了解如何使这个初始启动活动以横向模式显示,或者其他一些可以达到相同结果的方法。下面是启动活动的代码,带有违规的 ScreenOrientation 参数。

[Activity(
    Label = "The App Name",
    Icon = "@drawable/icon", 
    MainLauncher = true, 
    Theme = "@style/Theme.Splash", 
    //ScreenOrientation = ScreenOrientation.Landscape,
    NoHistory = true)]
public class ActivitySplash : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Start our real activity
        StartActivity(typeof(ActivityMain));
    }
}
4

4 回答 4

1

您所要做的就是在 Resources 中创建一个名为 drawable-land 的文件夹。然后,将 Splash.png 放在那里。不需要额外的 c#。

盖伊

于 2014-01-03T07:13:08.010 回答
0

我在 Nexus 7 上也遇到过类似的问题,如果你RequestedOrientation = ScreenOrientation.Landscape;在上面提到的OnCreate方法中使用,屏幕将在几秒钟内以纵向显示。

我还尝试将所有设置都放在初始屏幕的 .axml 及其样式中,但没有效果。

我能够使其工作的唯一方法是ScreenOrientation = ScreenOrientation.Landscape在 Activity 注释中设置属性

[Activity(Label = "MySplashScreen", Theme = "@style/SplashTheme", NoHistory = true, MainLauncher = true, ScreenOrientation = ScreenOrientation.Landscape)]
    public class SplashScreenActivity : Activity
{
// your code goes here ...
}

这是我让它正常工作的唯一方法。我认为您应该使用它并调查设置此属性时为什么不显示图像。

于 2013-07-22T15:06:08.617 回答
0

尝试将以下行添加到您的初始屏幕活动中。

RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape;

像这样:

[Activity(
    Label = "The App Name",
    Icon = "@drawable/icon", 
    MainLauncher = true, 
    Theme = "@style/Theme.Splash", 
    //ScreenOrientation = ScreenOrientation.Landscape,
    NoHistory = true)]
public class ActivitySplash : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);


        RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape;


        // Start our real activity
        StartActivity(typeof(ActivityMain));
    }
}
于 2012-12-12T12:43:01.883 回答
0

我知道这篇文章很旧,但对于那些在这里登陆的人来说:使用 xml 布局,中间有一个图像。这是他们在此处显示的 Xamarin Splash Screen 演示中的操作方式: Splash Screen Demo

于 2017-08-07T21:33:45.447 回答