【发布时间】:2022-01-07 12:59:14
【问题描述】:
首先,这是我的 style.xml 代码:
<style name="MainTheme" parent="MainTheme.Base">
<item name="colorAccent">#FF4627</item>
</style>
<style name="MyTheme" parent="android:style/Theme.Material.Light.DarkActionBar">
<item name="android:colorPressedHighlight">@color/ListViewSelected</item>
<item name="android:colorLongPressedHighlight">@color/ListViewHighlighted</item>
<item name="android:colorFocusedHighlight">@color/ListViewSelected</item>
<item name="android:colorActivatedHighlight">@color/ListViewSelected</item>
<item name="android:activatedBackgroundIndicator">@color/ListViewSelected</item>
<item name="android:colorEdgeEffect">#FF4627</item>
</style>
<style name="splashscreen" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/MDPI</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
<color name="ListViewSelected">#E39696</color>
<color name="ListViewHighlighted">#E39696</color>
</resources>
这是我在 MainActivity.cs 中更改的内容:
[Activity(Label = "Arboapp", Icon = "@drawable/ic_launcher", Theme = "@style/MainTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]
这是我的 SplashActivity.cs:
[Activity(Label = "Arboapp", MainLauncher =true, Theme ="@style/splashscreen", NoHistory =true, Icon = "@drawable/icon")]
public class SplashActivity : AppCompatActivity
{
protected override async void OnResume()
{
base.OnResume();
StartActivity(typeof(MainActivity));
}
}
然后我用正确分辨率的文件填充每个 mipmap 文件夹(包括可绘制对象)。
即使这样,我得到的 spla 屏幕图像也是失真的。
应该是这样的:
【问题讨论】:
-
这个问题多年来被问过很多次。在发布问题之前,请进行彻底的谷歌搜索。 (我已将标题编辑为技术上正确的术语,以说明正在发生的事情。)谷歌
xamarin android splash screen image stretched。众多问答之一:Show splash screen image with auto fit - 我选择了那个,因为“自动适应”是您想要发生的事情的术语。 (填充而不拉伸)。
标签: xamarin xamarin.forms xamarin.android splash-screen android-drawable