【问题标题】:Ripple effect over colored ImageButton?彩色ImageButton上的涟漪效应?
【发布时间】:2015-05-21 07:09:27
【问题描述】:

我有一个动态创建的 ImageButton。这是我的代码-

ImageButton bar = new ImageButton(this);

... //some code

parentView.addView(bar);

单击 ImageButton 时出现波纹效果。但是当我添加以下行时 -

bar.setBackgroundColor(Color.RED);

涟漪效应不再出现。有什么办法可以让彩色 ImageButton 上出现波纹效果?


涟漪效应是指这种效果 - click here(很抱歉,由于不支持 gif,因此我无法在此处添加图片)

【问题讨论】:

    标签: java android android-layout dynamic


    【解决方案1】:

    不妨试试这样的:

    bar.getBackground().setColorFilter(Color.RED, Mode.MULTIPLY);
    

    你需要检查什么模式是合适的,因为我没有这方面的丰富经验。

    【讨论】:

    • 非常感谢!这是工作。但唯一的问题是图像按钮的大小发生了变化。 imageButton 变小,边缘变圆。有什么办法可以防止吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-25
    • 2017-05-23
    • 1970-01-01
    • 1970-01-01
    • 2016-12-01
    • 2019-09-15
    • 1970-01-01
    相关资源
    最近更新 更多