[英]Splash screen Error default image size is too big
我正在嘗試在我的應用程序中顯示 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 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();
}
}
我正在嘗試在我的應用程序中顯示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();
}
}
嘗試使用這個
<item android:drawable="@drawable/logo" android:gravity="center" android:adjustViewBounds="true" android:scaleType="centerCrop" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.