I create a custom view and add selector to my custom view. Selector works, but background stretches full width and height. And background must displays what I draw. Full code http://pastebin.com/dmF6DiP8
@Override
protected void onDraw(Canvas canvas)
{
Log.d(TAG, "init onDraw");
if (canvas != null && mDrawable != null)
{
mDrawable.setState(getDrawableState());
canvas.drawCircle(mWidth / 2, mHeight / 2, mRadius, mBackgroundPaint);
mDrawable.draw(canvas);
}
}
Now normal state:
Now pressed state:
Must be:
What you are doing is drawing the circle first and then drawing a your drawable on top of it. The circle is underneath the drawable so you can't see it. The circle is also being drawn with the same color every time and it is not taking it from the drawable at all.
What you need to do is apply the color to the circle depending on the selector state and remove the call to draw the drawable on the canvas.