我不明白为什么这是一个透支,而我的SplashActivity
有一个布局只包括<ImageView .../>
和null
背景drawable set为窗口。
以下是活动的onCreate
的代码:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.setBackgroundDrawable(null)
setContentView(R.layout.activity_splash)
}
和activity_splash
内容:
<?xml version="1.0" encoding="utf-8"?>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:src="@drawable/splash"
android:scaleType="centerCrop"
tools:context=".feature.splash.SplashActivity"
tools:ignore="ContentDescription"/>
但是,如果过度绘制调试模式打开 - 图像显然是蓝色的。为什么?我无法真正了解透支的来源。
像这样设置imageview background null: -
android:background="null"
从imageview backround标签中删除@
出乎意料的是,解决方案是将window.setBackgroundDrawable(null)
放在setContentView(...)
之后。之后,透支就消失了。