Styles & Themes in Android

R.layout.single_item

A style is a collection of attributes that specify the look and format for a View. A style can specify attributes such as height, padding, font color, font size, background color, and much more.

We need to create your widget styles and add that in your app theme and finally add your app theme in manifest.

No need to mention the style in every view. like this Inside values folder in the styles file

The attributes related to style have been removed from the layout XML and put into a style definition called AppTheme, which is then applied using the android:theme attribute. To create the AppTheme style, save an XML file in the res/values/ directory of your project. Here is an example:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textViewStyle">@style/TextViewStyle</item>
</style>

<style name="TextViewStyle" parent="android:Widget.TextView">
<item name="android:background">@color/TextView_background</item>
<item name="android:textColor">#16F20A</item>
<item name="android:textStyle">bold</item>
</style>

In Your manifest file inside application tag add the below line.

<application android:theme="@style/AppTheme"> </application>

Ramasamy

I started to learn android and Kotlin and iOS and Hybrid application and i cant code IOS very well. But i love more interesting to code and finding new developer minds who are join to me You're welcome to keep on using my website.Instead, you can join our FB page for developer comments and post there: https://www.facebook.com/ramasamy.m.779 Best wishes :) Ramasamy(Software Developer)

Android Development and IOS Development & React Native Application

See what's new in Android & IOS & Hybrid development … explore and learn in site

About Ramasamy

Kotlin and React native example too

Related Posts

3 Comments

Ramasamy

5 min ago

Kotlin and React native example too

Reply

Ramasamy

5 min ago

Kotlin and React native example too

Reply

Ramasamy

5 min ago

Kotlin and React native example too

Reply

Leave a reply