【问题标题】:Different splash screen on screen orientation屏幕方向上的不同启动画面
【发布时间】:2016-10-23 13:33:04
【问题描述】:

我想在启动屏幕上显示不同的图像(不同尺寸的相同图像),纵向和横向,xamarin 形式的 android 应用程序。 这是我的资源文件夹的结构: Resources

这里是启动画面:

[Activity(Theme = "@style/Theme.Splash", //Indicates the theme to use for this activity
         MainLauncher = true, //Set it as boot activity
         NoHistory = true, //Doesn't place it in back stack
         ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class SplashActivity : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        System.Threading.Thread.Sleep(10000);

        this.StartActivity(typeof(MainActivity));
    }
}

我总是从可绘制文件夹中获取图像,然后将其横向拉伸。有人有什么想法吗?

【问题讨论】:

    标签: android xamarin.forms xamarin.android splash-screen


    【解决方案1】:

    您好,尝试将您用作启动画面的图像以不同的分辨率添加到这些不同的可绘制文件夹 mdpi、hdpi、xhdpi、xxhdpi

    如果这不起作用,请尝试使用这些属性创建背景项目

    <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
     android:src="@drawable/AndroidSplashScreen"
     android:gravity="clip_horizontal|clip_vertical" 
     />
    

    但最好的方法是使用 9-patch 图像或尝试使用 android 中的最新矢量图像,可以从新版本的 android studio 生成当前图像的矢量资源

    希望这会有所帮助:)

    【讨论】:

    • 位图属性应该放在哪里?
    • @sajidzahir 我的 splashStyle.xml 看起来像这样:&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;resources&gt; &lt;style name="Theme.Splash" parent="android:Theme.Holo.NoActionBar.Fullscreen"&gt; &lt;item name="android:windowBackground"&gt;@drawable/splash&lt;/item&gt; &lt;item name="android:windowNoTitle"&gt;true&lt;/item&gt; &lt;item name="android:windowFullscreen"&gt;true&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt;
    • 您好,为背景创建另一个 xml 并在其中添加位图现在将其设置为背景 schemas.android.com/apk/res/android"> schemas.android.com/apk/res/android" android:src="@drawable/AndroidSplashScreen" android:gravity="clip_horizo​​ntal|clip_vertical" /> 列表>
    • 这不起作用。该应用程序似乎总是使用启动画面的纵向版本。当以横向模式启动应用程序时,需要进行哪些更改才能确保应用程序实际使用“-land”文件夹中的图像?
    猜你喜欢
    • 2022-11-13
    • 1970-01-01
    • 1970-01-01
    • 2015-07-07
    • 2018-04-08
    • 2023-02-10
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    相关资源
    最近更新 更多