In the file res / values / styles.xml you add your style:
<style name="styleMyButton" parent="android:style/Widget.Button"> > <item name="android:background">@drawable/custom_background_selector</item> <item name="android:padding">12dp</item> <item name="android:layout_width">wrap_content</item> <item name="android:layout_width">wrap_content</item> <item name="android:textSize">24sp</item> </style>
Values in styles correspond to attribute names. It is best to inherit the style from the View for which this style will be applied - this will allow you to "pick up" the attributes by default. Here is the inheritance from the style for the Button
Then use:
<Button android:id="@+id/button1" style="@style/styleMyButton" android:text="@string/text_button1"/> <Button android:id="@+id/button2" style="@style/styleMyButton" android:text="@string/text_button2"/>
It will not be superfluous to examine the Android framework (and \ or AppCompat library , if it is used) in the styles.xml file to find out all the attributes available for redefinition (to change default values), so you can naturally add your own attributes.
You can also access the system's styles.xml files directly in the IDE in a way similar to this answer , just follow the res / values / folder