我想设置我的应用程序图标(位于屏幕中央底部的@drawable/app_icon.png
。我已经尝试了以下内容,但它只将图标放在左下角。
<!-- @drawable/splash_bg.xml -->
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@android:color/white"/>
<item
android:start="0px"
android:end="0px"
android:width="300px"
android:height="133px"
android:gravity="bottom">
<bitmap
android:layout_width="match_parent"
android:src="@drawable/app_logo" />
</item>
</layer-list>
而且我也尝试android:gravity="center"
添加到位图中,但它只是像素化图像。
尝试删除 android:layout_width="match_parent" 并添加 android:gravity="center">
这就是我创建初始屏幕的方式
安卓清单.xml
<activity android:name=".SplashActivity" android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
风格.xml
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:background">@drawable/background_splash</item>
<item name="android:windowAnimationStyle">@null</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
可绘制/background_splash.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Fill the background with a solid color -->
<item android:drawable="@color/colorWhite"/>
<!-- Place your bitmap in the center -->
<item>
<bitmap android:gravity="center" android:src="@mipmap/splash_land"/>
</item>
</layer-list>