OK, I know this issue has been covered in different questions but I'm trying a different approach here.
This is my custom View class:
public class MyView extends View {
Button mButton;
public MyView(Context context) {
super(context);
mButton = new Button(context);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//Sets the size needed.
}
@Override
protected void onDraw(Canvas canvas) {
canvas.save();
//Draws some graphics.
canvas.restore();
canvas.save();
RectF boundRect = new RectF(left,top,right,bottom);
canvas.clipRect(boundRect);
mButton.layout(0,0,canvas.getWidth(),canvas.getHeight());
mButton.draw(canvas);
canvas.restore();
}
}
This draws the button in the correct position and size, but, the button seems half transparent and is not clickable. Does anybody know why and how to fix it?