---
title: "Style and Theme in Android"  
description: "Hi everyone in this article I’m explaining about Style and Theme in Android."  
author: "Manoj Pandey"  
published: 2015-02-24  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1602/style-and-theme-in-android  
category: "android"  
tags: ["android", "style", "android styles"]  
reading_time: 3 minutes  

---

# Style and Theme in Android

Android allow you to define the look and feel, for example colors and fonts, of Android [components](https://www.mindstick.com/blog/74096/understanding-the-role-of-some-integral-ac-components) in XML [resource files](https://www.mindstick.com/forum/23026/c-sharp-tool-generates-res-files-binary-resource-files). This way you have to set common style [attributes](https://www.mindstick.com/articles/13105/2-attributes-that-make-your-odoo-ecommerce-theme-productive-and-engaging) only once in one central place.\

##### A style is a properties of view in android which specify the format of view.

A style is a set of one or more formatting attributes that you can apply as a unit to single elements in your layout [XML file](https://www.mindstick.com/articles/75/how-to-read-and-write-xml-file-through-c-sharp)(s). For example, you could define a style that specifies a certain text size and color, then apply it to [instances](https://answers.mindstick.com/qa/92508/how-can-you-hide-the-sql-server-instances) of a certain type of View element.

A theme is a set of one or more formatting attributes that you can apply as a unit to all [activities](https://www.mindstick.com/interview/2242/differentiate-activities-from-services) in an application or just a single activity. For example, you could define a theme that sets specific colors for the window frame and the panel foreground and [background](https://www.mindstick.com/articles/65/how-to-change-background-color-of-tab-control-in-c-sharp), and sets text sizes and colors for menus, then apply it to the activities of [your application](https://answers.mindstick.com/qa/95487/how-do-you-troubleshoot-when-your-application-link-is-not-responding).

You can add your custom style and theme in res/style.xml file

##### Here I am creating sample application with custom styles and themes.

##### \
1. Create an Android application

##### \
2. Go to the res\values\styles.xml

##### \
3. Add style. i.e.

##### \
Add style for button \

```
<style name="btnStyle">        <item name="android:layout_marginTop">30sp</item>        <item name="android:capitalize">characters</item>        <item name="android:typeface">monospace</item>        <item name="android:shadowDx">1.2</item>        <item name="android:shadowDy">1.2</item>        <item name="android:shadowRadius">2</item>        <item name="android:textColor">@android:color/holo_red_light               </item>        <item name="android:shadowColor">#000000</item>    </style>
```

Add style for TextView

```
<style name="textviewStyle">        <item name="android:textColor">#477519</item>        <item name="android:background">#D17519</item>        <item name="android:textSize">22sp</item>        <item name="android:typeface">monospace</item>        <item name="android:gravity">center</item>        <item name="android:layout_width">fill_parent</item>        <item name="android:padding">5sp</item>    </style>
```

Add style for Spinner

```
<style name="SpinnerStyle" parent="@android:style/Widget.Spinner.      DropDown">        <item name="android:gravity">center</item>        <item name="android:layout_marginTop">20sp</item>        <item name="android:textColor">#477519</item>    </style>
```

Add style for Edittext

```
<style name="EditTextStyle"> <item name="android:layout_marginTop">20sp</item> <item name="android:textColor">@android:color/holo_red_light</item> <item name="android:hint">Enter Your Name</item> <item name="android:layout_width">fill_parent</item> </style>
```

Add style in view

```
<TextView        style="@style/textviewStyle"        android:layout_width="fill_parent"        android:layout_height="wrap_content">
```

\

##### 4. My activity_main.xml

\

```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"    android:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    tools:context=".MainActivity" >     <TextView        style="@style/textviewStyle"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="@string/android" />     <Spinner        android:id="@+id/spinner"        style="@style/SpinnerStyle"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:prompt="@string/prompt" />     <EditText        style="@style/EditTextStyle"        android:layout_width="fill_parent"        android:layout_height="wrap_content" />     <Button        style="@style/btnStyle"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="@string/hello_world" /> </LinearLayout>
```

Run your application

![Style and Theme in Android](https://www.mindstick.com/mindstickarticle/4a74b987-62da-4114-b011-e997b995df89/images/c4772490-6e0a-4bec-adf0-b3f708767b45.png)

For apply all view

```
<style name="myTheme" parent="AppBaseTheme">         <!-- All customizations that are NOT specific to a particular          API-level can go here. -->        <item name="android:capitalize">characters</item>        <item name="android:typeface">monospace</item>        <item name="android:shadowDx">1.2</item>        <item name="android:shadowDy">1.2</item>        <item name="android:shadowRadius">2</item>        <item name="android:textColor">@android:color/holo_red_light</           item>        <item name="android:shadowColor">#000000</item>    </style>
```

And change theme from AndroidManifest.xml file

```
<application        android:allowBackup="true"        android:icon="@drawable/ic_launcher"        android:label="@string/app_name"        android:theme="@style/myTheme" >
```

##### Run your application

![Style and Theme in Android](https://www.mindstick.com/mindstickarticle/4a74b987-62da-4114-b011-e997b995df89/images/d6c84145-67c5-4f7a-8d7a-07134c3b7a79.png)

---

Original Source: https://www.mindstick.com/articles/1602/style-and-theme-in-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
