Android training (android style)

765 views

Published on

Android training (android style)
android, theme,style

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
765
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
39
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Android training (android style)

  1. 1. Layout Style Android Training By Khaled Anaqwa
  2. 2. Styles and Themes    A style is a collection of properties that specify the look and format for a View or window. A style can specify properties such as height, padding, font color, font size, background color, and much more. Styles in Android share a similar philosophy to cascading stylesheets in web design—they allow you to separate the design from the content.
  3. 3. <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#00FF00" android:typeface="monospace" android:text="@string/hello" />
  4. 4. Will be <TextView style="@style/CodeFont" android:text="@string/hello" />
  5. 5. Defining Styles  To create a set of styles, save an XML file in the res/values/ directory of your project.  The root node of the XML file must be <resources>.  For each style you want to create, add a <style> element to the file with a name that uniquely identifies the style (this attribute is required).
  6. 6. <?xml version="1.0" encoding="utf-8"?> <resources> <style name="CodeFont" parent="@android:style/TextAppearance.Medium"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:textColor">#00FF00</item> <item name="android:typeface">monospace</item> </style> </resources>
  7. 7. Inheritance  The parent attribute in the <style> element lets you specify a style from which your style should inherit properties. <style name="GreenText" parent="@android:style/TextAppearance"> <item name="android:textColor">#00FF00</item> </style>
  8. 8. Inheritance  If you want to inherit from styles that you've defined yourself, you do not have to use the parent attribute. <style name="CodeFont.Red"> <item name="android:textColor">#FF0000</item> </style>
  9. 9. Theme A theme is a style applied to an entire activity or application, rather than an individual View. android:theme="@android:style/Theme.Dialog”  The technique of defining a theme is the same as defining a style.
  10. 10. <?xml version="1.0" encoding="utf-8"?> <resources> <style name="MyTheme" parent="android:Theme.Dialog"> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@color/translucent_red</item> <item name="android:textColor">#00FF00</item> </style> </resources>  android:theme=”@style/MyTheme”

×