我正在尝试在我的应用程序中显示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>
style.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();
}
}
答案 0 :(得分:0)
尝试使用
<item android:drawable="@drawable/logo" android:gravity="center" android:adjustViewBounds="true" android:scaleType="centerCrop" />