首页 > 解决方案 > 启动画面错误默认图像尺寸太大

问题描述

我正在尝试在我的应用程序中显示 SplashScreen。代码与所有教程或文档相同,但我的问题是图标,我从 mipmap 放置了默认图标,但它看起来像这样 在此处输入图像描述

当我使用任何图片或图标时,我如何控制大小?,因为默认图标具有正确的大小。编码

xml

<?xml version="1.0" encoding="utf-8"?>
  <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/colorPrimaryDark" /><!-- color de fondo -->
<item>
    <bitmap
        android:gravity="center"
        android:src="@mipmap/ic_launcher" /> <!-- imagen centrada -->
</item>

样式.xml

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@mipmap/ic_launcher</item>
</style>

活动

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = new Intent(this, LoginActivity.class);
        startActivity(intent);
        finish();
    }
}

标签: javaandroid

解决方案


尝试使用这个

 <item android:drawable="@drawable/logo" android:gravity="center" android:adjustViewBounds="true" android:scaleType="centerCrop" />

推荐阅读