彩色 ImageButton 的涟漪效应?
Ripple effect over colored ImageButton?
我有一个动态创建的 ImageButton。这是我的代码 -
ImageButton bar = new ImageButton(this);
... //some code
parentView.addView(bar);
当我点击图像按钮时出现波纹效果。但是当我添加以下行时 -
bar.setBackgroundColor(Color.RED);
涟漪效应不再出现。有什么方法可以使波纹效果出现在彩色 ImageButton 上?
涟漪效应,我指的是这种效果 - click here(很抱歉,我无法在此处添加图像,因为不支持 gif)
也许可以试试这样:
bar.getBackground().setColorFilter(Color.RED, Mode.MULTIPLY);
您需要检查哪种模式合适,因为我对此经验不足。
我有一个动态创建的 ImageButton。这是我的代码 -
ImageButton bar = new ImageButton(this);
... //some code
parentView.addView(bar);
当我点击图像按钮时出现波纹效果。但是当我添加以下行时 -
bar.setBackgroundColor(Color.RED);
涟漪效应不再出现。有什么方法可以使波纹效果出现在彩色 ImageButton 上?
涟漪效应,我指的是这种效果 - click here(很抱歉,我无法在此处添加图像,因为不支持 gif)
也许可以试试这样:
bar.getBackground().setColorFilter(Color.RED, Mode.MULTIPLY);
您需要检查哪种模式合适,因为我对此经验不足。