How to create xml theme and style for android project

How to create a style theme file in android 4.2. How to apply this theme to all activities from the Android project. How to set this style and theme on multiple screens?

http://developer.android.com/guide/topics/ui/themes.html >

+4
source share
1 answer

Create a file called styles.xml in the res / values ​​directory of your application. Add the root root. For each style or theme, add an element with a unique name and, optionally, a parent attribute. The name is used to refer to these styles later, and the parent pointer indicates which style resource is inherited. Inside an element, declare format values ​​in one or more elements. Each identifies its style property with the name attribute and determines its style value inside the element. You can then reference user resources from other XML resources, your manifest, or application code.

A theme is a style that applies to an entire Office or application,

<style name="MyTheme" parent="android:Theme.Light"> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@color/translucent_red</item> <item name="android:listViewStyle">@style/MyListView</item> </style> <style name="MyListView" parent="@android:style/Widget.ListView"> <item name="android:listSelector">@drawable/ic_menu_home</item> </style> 

To define the style, save the XML file in the / res / values ​​directory of your project. The root node file of the XML file should be.

 <?xml version="1.0" encoding="utf-8"?> <resources> <style name="text"> <item name="android:padding">4dip</item> <item name="android:textAppearance">?android:attr/textAppearanceLarge</item> <item name="android:textColor">#000000</item> </style> <style name="layout"> <item name="android:background">#C0C0C0</item> </style> </resources> 

In your AndroidManifest.xml, apply the theme to the types of actions you want to use:

  <activity android:name="com.myapp.MyActivity" ... android:theme="@style/MyTheme" /> 
+4
source

All Articles