Recent Changes‎ > ‎

Extract Style Refactoring

posted Apr 4, 2011, 10:33 AM by Tor Norbye
We have a new refactoring which lets you pull out style-related attributes from your layout and extract them as a new style defined in styles.xml. Here's an example:
Here we have applied the wizard to a selection of multiple attributes. As you can see some of the attributes differ in their values for certain attributes, so in the wizard you can choose not just which attributes to extract, but also which value to extract.  You can also choose whether you want to remove just the attributes that were extracted, or all attributes of the same name but regardless of value, which lets you unify the look of the layout. The number in parentheses behind each value is a count for the number of occurrences of that attribute value among the elements, to give you a sense of which value is most common. (The values are also sorted by this count first, and when identical they are sorted alphabetically.)

If all elements are of the same widget type, you also get the option to set a parent for your style; the refactoring figures out the theme style which applies to the widget type, and makes that the parent of the new style:

Details: https://review.source.android.com//#change,22029
Comments