android - 着色 ImageView 不适用于 Android 5.0。想法如何让它再次工作?

标签 android imageview android-imageview android-5.0-lollipop

在我构建的应用程序中,我注意到 ImageViews 在运行新的 Android Lollipop 的设备上没有着色。这是用于在旧版本操作系统上正常工作的代码:

<ImageView
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="bottom|right"
            android:contentDescription="@string/descr_background_image"
            android:src="@drawable/circle_shape_white_color"
            android:tint="@color/intent_circle_green_grey" />

这是在 ImageView 中加载的可绘制对象:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >
    <gradient android:startColor="@color/white" android:endColor="@color/white"
        android:angle="270"/>
</shape>

再一次,这在运行 JellyBean/Kitkat 的设备上工作正常,但色调对运行 Lollipop 的设备没有影响。任何想法如何解决它?这是操作系统中的错误,还是我应该开始对图像进行不同的着色?

最佳答案

像这样使用 AppCompatImageView:

<android.support.v7.widget.AppCompatImageView
        android:id="@+id/my_appcompat_imageview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/my_image"
        android:tint="#636363"
    />

确保您在应用的 build.gradle 中拥有最新的 compile 'com.android.support:appcompat-v7:23.4.0'

关于android - 着色 ImageView 不适用于 Android 5.0。想法如何让它再次工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27174893/

相关文章:

java - 无法设置ImagView的图像

android - CenterCrop 缩放类型不适用于使用 Picasso 加载的图像

android - 如何在单击 baseadapter 中的 ListView 项时更新文本

ios - 根据 UICollectionView 中 url 的 json 响应从应用程序内添加图像

android - 使用 jmDNS 注销 zeroconf 服务

android - 如何在 ImageView 上显示随机图像

java - 如何保持从 url 下载到 imageview 的图像质量并将它们裁剪成圆形?

android - 从 ImageView 获取图像

android - 我在 NetBeans 中看不到图形布局 android

android - 如何更改 EditText 中光标的外观?