Landscape splash-screen in android

How can I have a two different splash-screens from landscape and portrait mode? I have managed to get the portrait splash-screen for my android app, but for a 10" screen this portrait splash-screen seems to stretch the image. Here is my code:

SplashActivity.cs:

    [Activity(Theme = "@style/Theme.Splash", Label = "appName", MainLauncher = true, NoHistory = true, ScreenOrientation = ScreenOrientation.Portrait)]
        public class SplashActivity : Activity
        {
            protected override void OnCreate(Bundle savedInstanceState)
            {
               // Create your application here
                base.OnCreate(savedInstanceState);
                System.Threading.Thread.Sleep(1000); //Let's wait awhile...
                this.StartActivity(typeof(MainActivity));
            }
        }

Styles.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <resources>
      <style name="Theme.Splash" parent="android:Theme">
        <item name="android:windowBackground">@drawable/splash</item>
        <item name="android:windowNoTitle">true</item>
      </style>
    </resources>

And separate splah.png images are place in drawable, drawable-hdpi, drawable-xhdpi and drawable-xxhdpi folders.

Answers

  • Hi, did you find solution for this problem?
    I tried with using drawable and drawable-land folders, but that doesn't solved the problem.

  • Hi, same problem here using splashscreen image only in drawable-land and drawable-port folders and splashscreen is always from port folders

  • DeveshMishraDeveshMishra USMember ✭✭

    Any solution for this issues ?

  • ChristophHuberChristophHuber USMember ✭✭

    Still no solution for this issue?

  • RyanWatsonRyanWatson USMember ✭✭✭
    Running into this same issue. Anyone have a solution?
  • CharwakaCharwaka INMember ✭✭✭
    edited November 16

    Hi @mishtyNaik
    First of all add Landscape orientation also like this

    ScreenOrientation = ScreenOrientation.Portrait | ScreenOrientation.Landscape

    If you're specifying your splash screen layout in XML, you can place a landscape layout in the **res/layout-land **folder and an identically named portrait layout either in the default **res/layout **folder or a specific **res/layout-port **folder

    Or

    You can determine the orientation of the device at build time, and then display the appropriate splash screen

    public DeviceOrientations GetOrientation()
            {
                IWindowManager windowManager = Android.App.Application.Context.GetSystemService(Context.WindowService).JavaCast<IWindowManager>();
    
                var rotation = windowManager.DefaultDisplay.Rotation;
                bool isLandscape = rotation == SurfaceOrientation.Rotation90 || rotation == SurfaceOrientation.Rotation270;
                return isLandscape ? DeviceOrientations.Landscape : DeviceOrientations.Portrait;
            }
    

    Don't Forget to mark as answer

Sign In or Register to comment.