我爲Android應用程序創建了一個閃屏,並向其中添加了圖像,但打開應用程序後,圖像拉伸,我如何使圖像保留其寬高比而不是伸展在所有強制圖像在加載時保留其原始大小
這裏是我的Styles.xml代碼,圖像=的icon.png
我爲Android應用程序創建了一個閃屏,並向其中添加了圖像,但打開應用程序後,圖像拉伸,我如何使圖像保留其寬高比而不是伸展在所有強制圖像在加載時保留其原始大小
這裏是我的Styles.xml代碼,圖像=的icon.png
在你ImageView
附加:
android:adjustViewBounds="true"
android:scaleType="centerCrop"
沒有ImageView for SplashScreen的圖像,看看我的Styles.xml –
你必須創建使用layer-List
(splash.xml
)一個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>
<item>
<bitmap android:src="@drawable/icon" android:gravity="fill" android:antialias="true" android:dither="true"></bitmap>
</item>
</layer-list>
添加這個splash.xml
爲您閃屏的背景。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Splash" parent="android:Theme">
<item name="android:windowBackground">@drawable/splash</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
它正在解決這個問題,但我有一個方形圖像,我如何使它適合而不會丟失其縱橫比,重力沒有任何「centerCrop」設置 –
請檢查我的更新答案。 – tahsinRupam
爲什麼要將圖標設置爲背景? – tahsinRupam
它是一個高分辨率圖標,我只需要知道如何調整它的大小,是否可以通過編輯Styles.xml –
隨着圖像的伸展,您想放置在哪裏?在中心? – tahsinRupam