Android provides a system for separating our data from our design, in a manner similar to the way Cascading Stylesheets do in web design. Android Styles can be applied to single views or view groups and can inherit attributes from other styles.
Creating an Android Style requires a separate XML file to define it. Start up a new Android project in Eclipse and navigate to the res/values
folder.
Using the
res/values
folder's context menu, create a new XML file and call itmy_style.xml
:Open this file for editing. The wizard should have created a
<resources>
root node as follows:<?xml version="1.0" encoding="utf-8"?> <resources> </resources>
Inside the
<resources>
node, nest the following<style>
and<item>
elements:<style name="MyStyle"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:background...