gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:02:14 26 4
gpt4 key购买 nike

在我构建的应用程序中,我注意到 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com