有时 ImageView 显示为黑色

Sometimes ImageView Appears Black

我在我的应用程序中使用简单的 ImageView。

如下

 <ImageView
            android:id="@+id/imvTripArrow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:contentDescription="@null"
            android:src="@drawable/ic_arrow_roundtrip_white" />

我给这个ImageView设置的图标是白色的。 但有时它显示黑色而不是白色。(仅在设备 Nexus5 api 21)

下面是我Activity中使用的主题。

<style name="NoTitleBarCustom" parent="Theme.AppCompat.NoActionBar">
        <item name="windowNoTitle">true</item>
        <item name="windowActionModeOverlay">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:windowBackground">@android:color/black</item>
        <item name="android:textColorPrimary">@android:color/white</item><!-- tool bar text color-->
        <item name="colorPrimary">@android:color/white</item> <!-- tool bar-->
        <item name="colorPrimaryDark">@android:color/black</item> <!-- notification bar-->
        <item name="colorAccent">@android:color/white</item>
        <item name="android:windowTranslucentStatus">true</item>
    </style>

这个问题出现在我的应用程序中的许多 ImageView 中。 我搜索了很多有关此问题的信息,但没有找到任何解决方案。任何人请帮助!!!

使用 AppCompatImageView 而不是 ImageView。

<android.support.v7.widget.AppCompatImageView
        android:id="@+id/imvTripArrow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:contentDescription="@null"
        app:srcCompat="@drawable/ic_arrow_roundtrip_white"
        app:tint="#fff/>
        
           

在gradle中添加"vectorDrawables.useSupportLibrary = true"。

android {
    compileSdkVersion 28
    defaultConfig {
        .....    
        vectorDrawables.useSupportLibrary = true
    }