【问题标题】:Change Color of ImageButton on Scrolling? [duplicate]滚动时更改 ImageButton 的颜色? [复制]
【发布时间】:2015-09-14 13:03:40
【问题描述】:

我有以下 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 图片的颜色?

【问题讨论】:

  • 对drawable应用颜色过滤器。

标签: java android android-imagebutton


【解决方案1】:

您可能想尝试 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-26
    • 2013-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多