Android 1x在单个ImageView上透支

问题描述 投票:0回答:2

我不明白为什么这是一个透支,而我的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"/>

但是,如果过度绘制调试模式打开 - 图像显然是蓝色的。为什么?我无法真正了解透支的来源。

android android-imageview android-xml android-drawable
2个回答
0
投票

像这样设置imageview background null: -

 android:background="null"

从imageview backround标签中删除@


0
投票

出乎意料的是,解决方案是将window.setBackgroundDrawable(null)放在setContentView(...)之后。之后,透支就消失了。

© www.soinside.com 2019 - 2024. All rights reserved.