Xml 启动屏幕图像太长
我在我的可绘制文件夹中有图像,我将它们调整为标准尺寸,并将它们放在每个文件夹中。但是,当我启动应用程序并运行MainActivity时,我的SplashScreen图像会出现拉伸,在屏幕上看起来很糟糕。我在网上查看了答案,但没有任何效果 如何使图像在splashscreen上看起来正常 这是我的主要活动Xml 启动屏幕图像太长,xml,xamarin.forms,splash-screen,Xml,Xamarin.forms,Splash Screen,我在我的可绘制文件夹中有图像,我将它们调整为标准尺寸,并将它们放在每个文件夹中。但是,当我启动应用程序并运行MainActivity时,我的SplashScreen图像会出现拉伸,在屏幕上看起来很糟糕。我在网上查看了答案,但没有任何效果 如何使图像在splashscreen上看起来正常 这是我的主要活动 [Activity(Label = "Peppy", Icon = "@mipmap/bicon", Theme = "@style/peppy", MainLauncher =
[Activity(Label = "Peppy", Icon = "@mipmap/bicon", Theme = "@style/peppy", MainLauncher = true, NoHistory = true)]
public class SplashActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
StartActivity(typeof(MainActivity));
}
}
这就是我在style.xml中定义样式的方式
<style name="peppy" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/bluesplash</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:colorPrimaryDark">#1976D2</item>
</style>
<style name="Main Theme" parent="MainTheme.Base"></style>
@可拉深/蓝色板
真的
真的
#1976D2
我希望SplashScreen图像完全符合我的要求。谢谢我的drawables文件夹中有一个splashScreen.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/green_colour"/>
</item>
<item>
<bitmap
android:src="@drawable/splash_logo"
android:tileMode="disabled"
android:gravity="center"/>
</item>
</layer-list>
您是否也有引用splashScreen.xml中可绘制的样式?文档中有一个更完整的示例(类似于此答案)。之后的“实现主题”部分展示了如何使用启动屏幕xml。
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Support.V7.App;
using Android.Util;
using App1.Droid;
namespace com.xamarin.sample.splashscreen
{
[Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
static readonly string TAG = "X:" + typeof(SplashActivity).Name;
public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
{
base.OnCreate(savedInstanceState, persistentState);
Log.Debug(TAG, "SplashActivity.OnCreate");
}
// Launches the startup task
protected override void OnResume()
{
base.OnResume();
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
}
// Prevent the back button from canceling the startup process
public override void OnBackPressed() { }
}
}