简体   繁体   English

如何将 imageView 内的可绘制对象与另一个可绘制对象进行比较?

[英]How to compare a drawable inside an imageView with another drawable?

I have a drawable inside an imageView and I need to know which drawable is to modify it.我在 imageView 中有一个可绘制对象,我需要知道要修改哪个可绘制对象。

    <ImageView
    android:id="@+id/dice_image1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:src="@drawable/empty_dice"
    tools:src="@drawable/dice_1"/>

I already tried with constant state but it's deprecated and works sometimes我已经尝试使用常量 state 但它已被弃用并且有时可以工作

I found a solution.我找到了解决办法。 I put a tag inside each imageview to be able to track what image was inside.我在每个 imageview 中放了一个标签,以便能够跟踪里面的图像。 Every time I changed the image I updated the tag number.每次我更改图像时,我都会更新标签号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM