Recently I stumbled across this article on the official Android Developer site:
https://developer.android.com/training/custom-views/create-view#customattr
It explains how you can use XML to set specific attributes of your View class.
You could, for instance, define if a text is left or right aligned within your layout.xml file of the Activity or Fragment.
You could, however, also write a setter in the Java class.
Is there a recommendation when to use the one over the other?