The checkbox border is invisible on white background.

I played with di
Did you try going through here, here and here?
And as per answering your question
But why checkbox does not look okay in usual xml
Thats because sometimes, the android graphical view is not able to render the custom views, in that case you need to run the code on the emulator or the device to test it out.
UPDATE In case you dont want to use drawables, then you can also define the drawable shape in xml like