滚动时更改 ImageButton 的颜色?

Change Color of ImageButton on Scrolling?

我有以下 Android ImageButton:

<ImageButton
    android:id="@+id/myButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/my_button"
    android:background="@null" />

该按钮显示一个圆形图像,中间有一个透明加号。当用户滚动时,我想根据偏移量更改此按钮的颜色。

我试过使用 setBackgroundColor() 但这不是正确的方法,而且它不起作用。应该是我猜的颜色。

如何动态更改 ImageButton 图像的颜色?

您可能想尝试 vokilam 对类似问题的回答:

ImageButton button = (ImageButton) this.findViewById(R.id.button_i_want_to_modify);
button.setColorFilter(Color.argb(255, 255, 255, 255)); // White Tint

在此处找到: How do I change the tint of an ImageButton on focus/press