java - 启动画面错误默认图像尺寸太大
问题描述
我正在尝试在我的应用程序中显示 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();
}
}
解决方案
尝试使用这个
<item android:drawable="@drawable/logo" android:gravity="center" android:adjustViewBounds="true" android:scaleType="centerCrop" />
推荐阅读
- java - 如果您的值不固定,如何使用 Enum?
- c# - C# Excel Interop Chart Column Series Problem
- deep-learning - 如何计算人工智能或深度学习任务中的时钟频率(频率)?
- python - 使用逻辑回归时如何打印特征重要性的简单列表?
- c# - 如何创建一个 List(of T),其中 T 是 (T) 的接口,并且 List 的内容继承了一个实现 T 接口的抽象类
- cloudinary - cloudinary 下载PDF
- electron - 如何使电子预加载文件使用相同的类实例
- c++ - C++11 - 为什么编译器不优化对 const 左值引用绑定的右值引用?
- typescript - Vue + typescript:如何用类型注释计算?
- ios - 解析数组中的嵌套 json,如树 swifty json