Breaking News
Home / Android / Android Snippets / How do you define styles in Android?

How do you define styles in Android?

Answer
In order to define a styles that can be used as theme for your app widget or layout, define the styles as a resource in the file. The resource file can have any name but ends with .xml

e.g. the resource file can be named as styles.xml in the res/values directory of your project as:

res/values/styles.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <resources>
  4.  <style name="CodeFont" parent="@android:style/TextAppearance.Medium">
  5.       <item name="android:layout_width">fill_parent</item>  
  6.      <item name="android:layout_height">wrap_content</item>
  7.        <item name="android:textColor">#00FF00</item>  
  8.      <item name="android:typeface">monospace</item>  
  9.   </style>
  10. </resources>
[pb_builder]

Check Also

How to check if an Android device can connect to Internet?

The following code snippet shows how to check if an Android device can connect to …

Advertisment ad adsense adlogger