Иногда ImageView выглядит черным

Я использую простой 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)

ниже приведена тема, используемая в моей деятельности.

<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 в моем приложении. Я много ищу об этой проблеме, но не нашел решения. Кто-нибудь, пожалуйста, помогите!!!

1
0
73
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

используйте 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/>
        
           

Добавьте «vectorDrawables.useSupportLibrary = true» в gradle.

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

Другие вопросы по теме