In xml, I often do this to emulate onClick effect:
I was looking for the same solution. I slightly changed this answer to make it more suitable for the asked question. Call the following code from your constructor.
private void setClickableAnimation(Context context)
{
TypedValue outValue = new TypedValue();
context.getTheme().resolveAttribute(
android.R.attr.selectableItemBackground, outValue, true);
setForeground(getDrawable(context, outValue.resourceId));
}