我想要图片背景。当我将根元素的背景属性设置为图片时,由于纵横比的差异,它会变形。阅读了stackoverflow答案后,我将其更改为
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/wallpaper1"/>
该图像是300KB全高清图像。看起来不错,但是问题是当我开始活动时,会有口吃和警告消息。
I/Choreographer: Skipped 38 frames! The application may be doing too much work on its main thread.
当我删除ImageView时,就没有这样的问题。我不应该在布局XML中使用" SRC",并使用背景线程自行加载图像?
尝试将图像转换为.webp格式以降低图像大小,并使用无损编码类型来保持图像质量。
在Android Studio中
1。右键单击图像资产
2。单击转换为WebP
3。选择使用无损编码和点击(API 18 )