In your application, if you have some or many user interface components that have the same look and format, it is a good idea to have a style file that can used for the those components. Android allows you to define a style separated from content. This concept is similar to CSS in web design. You need to define a style in an xml file that is separated from the layout files of your user interface. The style files must be saved in the res/values folder. In the style file you can specify properties such as layout_width, layout_height, text color, font size, background color, and much more.
The root node of the XML file must be
. You can define many styles in a single xml file. You need to add the <style> tag to each style that you want to define. A style must have a unique name defined by the name attribute. Then you will use the <item> tag for each property of that style. The value of each property can be keyword string, a hex color, or any value depending the style property. A child style can inherit all the properties from its parent style. When you define a style, you can inherit all properties from a style that was defined by Android system using the parent attribute. In the example xml style file below, the first style (defined for TextView) inherit all properties from TextAppearance.Medium style of Android system. If you inherit properties from a style that was defined by your ownself, you do not have to use the parent attribute. Instead, just write the name of the style you want to inherit followed by a period and the name of your new style. The second style you see in the code below inherits all properties defined in the first style. You should note that when you write properties of a style, you need to make sure that the view that the style will be applied to supports those properties. Otherwise, the style will not work as you expected.
<?xml version="1.0" encoding="utf-8"?>
android:text="Enter the information about you"
android:hint="Enter country code"
Posted by: Dara | post date: 09-19-2014 | Subject: Android Apps Development
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: