How to retrieve the attribute values ​​from the android widget in Java?


I have extended Android's Button class and I would like to access some of the attribute values being set in the XML file through java code, for example, padding, gravity. Let me know how to achieve this...

in your constructor you get an AttributeSet and with obtainStyledAttributes you can access attributes from xml but some of these are private and not accessible through the sdk. also have a look at the source code from TextView especially the constructor starting @line 311.