Look at the XML code here please:
It works too inside Constraint Layout. Just add the following attributes on your TabLayout.
. . .