无法在动态绘制的视图上添加涟漪效果的可绘制对象。

4
我已经准备了一个自定义视图,其高度为x,宽度为y(通过扩展View实现)。此视图具有背景,在其中我绘制了可绘制对象。用户可以将该可绘制对象在其x和y限制内移动。现在,我想在按下和聚焦状态下添加涟漪效果。实际上,当此视图获得焦点时,我也无法将焦点集中在该可绘制对象上。
    public class CustomView extends View {
    Drawable image; 
    public CustomView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setFocusable(true);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.abc);
        image = a.getDrawable(R.styleable.x);
        mBackgroundImage =   a.getDrawable(R.styleable.y);
        this.setBackgroundDrawable(mBackgroundImage);
    }

   @Override
   protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int width = image.getIntrinsicWidth();
        int height = image.getIntrinsicHeight();
        location = calculatePosition();
        image.setBounds((int) location, 0, (int) (location + width), height);
        image.draw(canvas);
   }
}

我想在那个“image”上添加涟漪效果。我已经搜索了很多,但没有找到任何解决方案。然后我注册了stackoverflow,并发布了我的第一个问题。如果有人知道,请帮忙。

提前感谢。


1
你是否找到了解决这个问题的方法? - Raymond
我无法将涟漪效果添加到可绘制对象中,但我在可绘制对象上画了一个涟漪颜色的圆圈。它看起来和涟漪效果一样。 - Amitosh Agnihotri
1个回答

0

我无法将涟漪效果添加到可绘制对象中,但我在我的可绘制对象上画了一个涟漪颜色的圆圈。它看起来与涟漪效果相同。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接