I have prepapred a CustomView with x height and y width (by extending View). This view has a background. and in this view, I am drawing a drawable. User can move that drawable within its x and y limit. Now want to add ripple effect on that drawable for pressed and focused state. Actually I am also unable to focus on that drawable when this view is focused.
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);
}
}
I want to add ripple on that drawable "image". I have search a lot but not found any solution. Then i signed up in stackoverflow. and now posting my first question. If anyone knows, please help
Thanks in advance
I couldn't add ripple effect to drawable. but i draw a circle of ripple color on my drawable. It looks same as ripple effect