我的可绘制文件夹中有图像,并且将它们的大小调整为标准大小,然后将其放入每个文件夹中。但是,当我启动我的应用程序并运行MainActivity时,我的SplashScreen图像显示为拉伸状态,并且在屏幕上看起来很糟。我已经在线查看了答案,但没有任何效果。
我该怎么做才能使图像在初始屏幕上看起来正常。
这是我的MainActivity.cs
[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>
我希望SplashScreen图像能够完美地适合屏幕。谢谢
答案 0 :(得分:0)
我的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>
使图像居中而不变形。
活动就是这样
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() { }
}
}