我已经准备了一个具有x高度和y宽度的CustomView(通过扩展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);
}
}
我想在可绘制的“图像”上添加波纹。我已经搜索了很多,但没有找到任何解决方案。然后我注册了stackoverflow。现在发布我的第一个问题。如果有人知道,请帮忙
提前致谢
我无法在可绘制对象上添加波纹效果。但我在可绘制对象上绘制了一个波纹颜色的圆圈。看起来和涟漪效应一样
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句