A style is a group of common View attribute values. You can apply the style to individual View controls. Styles can include such settings as the font to draw with or the color of text. The specific attributes depend on the View drawn. In essence, though, each style attribute can change the look and feel of the particular object drawn.
In the previous examples of this chapter, you have seen how XML layout resource files can contain many references to attributes that control the look of TextView objects. You can use a style to define your application’s standard TextView attributes once and then reference to the style either in an XML layout file or programmatically from within Java.we see how you can use one style to indicate mandatory form fields and another to indicate optional fields. Styles are typically defined within the resource file res/values/styles.xml.The XML file consists of a resources tag with any number of style tags, which contain an item tag for each attribute and its value that is applied with the style.
The following is an example with two different styles:
When applied, this style sets the padding to two pixels and the textSize to eight pixels. The following is an example of how it is applied to a TextView from within a layout resource file:
Styles support inheritance; therefore, styles can also reference another style as a parent. This way, they pick up the attributes of the parent style. The following is an example of how you might use this:
Here you find two common attributes in a single style and a reference to them from the other two styles that have different attributes. You can reference any style as a parent style; however, you can set only one style as the style attribute of a View. Applying the padded_italics style that is already defined makes the text 14 pixels in size, italic, red, and padded.The following is an example of applying this style:
As you can see from this example, applying a style with a parent is no different than applying a regular style. In fact, a regular style can be used for applying to Views and used as a parent in a different style.
Here the padded_xlarge style is set as the parent for the green_glow style. All six attributes are then applied to any view that this style is set to.
Setting Up Your Android Development Environment
Writing Your First Android Application
Understanding The Anatomy Of An Android Application
Defining Your Application Using The Android Manifest File
Managing Application Resources
Exploring User Interface Screen Elements
Designing User Interfaces With Layouts
Drawing And Working With Animation
Using Android Data And Storage Apis
Sharing Data Between Applications With Content Providers
Using Android Networking Apis
Using Android Web Apis
Using Location-based Services (lbs) Apis
Using Android Multimedia Apis
Using Android Telephony Apis
Using Android 3d Graphics With Opengl Es
Using The Android Ndk
Using Android’s Optional Hardware Apis
Working With Notifications
Working With Services
Extending Android Application Reach
Managing User Accounts And Synchronizing User Data
Handling Advanced User Input
Targeting Different Device Configurations And Languages
The Mobile Software Development Process
Designing And Developing Bulletproof Android Applications
Testing Android Applications
Selling Your Android Application
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.