Igo*_*yuk 38 android splash-screen
我正在尝试使用新的 Splashscreens API替换 Android 应用程序中旧的基于活动的启动屏幕
所以我创建了我的应用程序徽标的 svg,创建了主题,并在我的 MainActivity 中进行设置,但是installSplashScreen
应用程序启动时,启动画面中的徽标如下所示:
我该如何解决这个问题?
这是我所做的 style.xml:
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/colorAccent</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_visual_vector</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>
Run Code Online (Sandbox Code Playgroud)
显现:
<activity
android:name=".MainActivity"
android:theme="@style/Theme.App.Starting"
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
主要活动:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SplashScreen.installSplashScreen(this);
setContentView(R.layout.activity_main);
...
Run Code Online (Sandbox Code Playgroud)
laa*_*lto 56
您可以做的是将图标包装在可绘制的插图中,以便将其绘制在圆圈内。
例如,创建一个drawable/splash_inset.xml
资源:
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_visual_vector"
android:insetLeft="72dp"
android:insetRight="72dp"
android:insetTop="72dp"
android:insetBottom="72dp"/>
Run Code Online (Sandbox Code Playgroud)
实际的插入值取决于您的图像及其纵横比,72dp
此处以所有边缘为例。
然后将此可绘制对象应用为您的windowSplashScreenAnimatedIcon
.
SLy*_*Huy 10
在 Android 12 中,如果您的图标大于所需的尺寸,它将被截掉。
\n没有图标背景的应用程序图标:这应该是 288\xc3\x97288 dp,并且适合直径 192 dp 的圆。
\n例如,如果图像的完整大小为 300\xc3\x97300 dp,则图标需要适合直径为 200 dp 的圆。圆之外的所有内容都将不可见(被遮蔽)。
\n\n更多信息:https ://developer.android.com/guide/topics/ui/splash-screen#elements
\nEll*_*otM 10
我发现最可靠的方法是使用 Asset Studio 创建自适应图标,它涵盖了 DPI 的所有场景。插图方法只会引导您为不同的 DPI 映射不同的插图,该工具会为您完成所有这些工作,并向您显示可以在哪里剪切图像。
然后将启动屏幕图标指向生成的 mipmap
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_splash_screen</item>
使用调整大小滑块!