Course Content

Course Content

Styles Android Example

Android Style and Theme Example

We have seen the concept of Style, how we can design a particular view into a specific style whether it's textView, editText, or button. And when we apply such Style to whole application it becomes a 'Theme'. Now we will see both of this Android Style and Themes Example concept practically.

First of all we will create a project named 'MyTheme'.

Firstly we will design its layout, for that we will open our 'activity_main.xml' file from 'layout' folder. In this we have used the default relative layout, and have take a textview with its ID set as 'textView2'.

After that we will provide text,

android:text=""Welcome To My Theme Demo!""


Now to design style we will go to 'values' folder, and than open 'colors.xml' file,

<color name=""colorPrimary"">#FF4081</color>

<color name=""colorPrimaryDark"">#303F9F</color>

We'll use this two colors to change in Statusbar and Titlebar.

After that we will open 'styles.xml' file, and then we will specify dress styles,

<style name=""AppTheme"" parent=""Theme.AppCompat.Light.DarkActionBar"">

<item name=""android:colorPrimary"">@color/colorPrimary</item>

<item name=""android: colorPrimaryDark"">@color/colorPrimaryDark</item>



Now we will design second style for textview,

<style name=""MyTextViewStyle"" parent=""@android:style/TextAppearance.Large"">

<item name=""android:layout_width"">fill_parent</item>

<item name=""android:layout_height"">wrap_content</item>

<item name=""android:textColor"">4006633</item>

<item name=""android:typeface"">monospace</item>

<item name=""android: background"">#f07977</item>

<item name=""android:textStyle"">bold</item>



Now to apply theme we will first go to our manifest file, now in that default code we will apply theme,



Now we will apply at second style in this manifest file, for that we will open layout 'activity_main.xml' file, and add our style,



So now in this particular program, we have not changed any default code of our '' file. We have just added our style and theme code in Manifest and Layout file.

After executing, this program runs successfully.


Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
App Store
297K+ Downloads
App Download Section Circle 1
4.5 Rating
App Download Section Circle 2
10K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere