我正在尝试添加一个启动屏幕,我执行了以下步骤,它在android 11上运行。
implementation
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/black" />
</shape>
</item>
<item
android:gravity="center"
android:drawable="@drawable/ic_my_splash_icon">
</item>
</layer-list>中的分层列表
<style name="SplashTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/black</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
<item name="postSplashScreenTheme">@style/Theme.AppTheme</item>
</style>将清单主题更改为SplashTheme
这对于Android11API30非常有效,但是图像被拉伸得超出了比例,并被裁剪在图标圈内,用于Android12API31,我的图标是一个矩形字形的设计。
我读到其中一个答案,建议在分层列表中添加位图,但在添加位图之后,图标不会呈现在android工作室的设计视图中,运行该应用程序时,我只会看到一个黑色屏幕。
<item>
<bitmap
android:gravity="center"
android:drawable="@drawable/ic_my_splash_icon"/>
</item>我也不被允许手动输入尺度尺寸来使它看起来更好。
发布于 2021-11-09 17:57:21
我一直在处理同样的问题。使用巴布亚新几内亚资产留给我一个超大的圆圈从我的标志。最后为我工作的是将我的徽标转换为SVG,并通过Vector工具将其添加到项目中。
编辑:如果SVG资产超过一定的大小,它又变成了一个圆。这个截止符的尺寸看起来很小。
为了改变splash屏幕的徽标大小,我在图标周围填充了SVG资产,这与我的背景色相匹配。这就愚弄了Vector工具,使它降到了我想要的大小。
发布于 2021-11-18 02:26:10
我也面临过同样的问题。我有一个长径比为1x2的PNG资产,在1.0.0.alpha02上被裁剪得非常糟糕。因此,为了解决这个问题,我使用Adobe XD将这个PNG资产转换为平方108 to到108 asset文件,并通过Vector工具作为一个XML文件添加到我的可绘制文件夹中。然后,我在SplashScreen的themes.xml主题上使用了这个XML文件,最终使一切正常工作。
另外,正如上面提到的CodeBlue04,您需要在您的徽标中添加一些垫子,在我的例子中,垫片等于18 my。
https://stackoverflow.com/questions/69896786
复制相似问题