codepath/android-theme-switcher

Name: android-theme-switcher

Owner: CodePath

Description: An android app that changes custom themes at runtime.

Created: 2015-06-29 03:59:25.0

Updated: 2018-04-01 22:32:18.0

Pushed: 2017-10-18 05:29:45.0

Homepage: null

Size: 90

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

android-theme-switcher

An android app that changes custom themes at runtime.

Overview

The goal of this exercise is to get familiar with Android drawables, styles and themes. By the end of this exercise, you should know how to define a theme in your resources in an XML file, how to define attributes of the theme, how to apply those to your layout file, and finally how to dynamically change the theme of an activity.

Usage

This app is intended to be the base project on top of which new features can be added. To use it, clone the project and import it using the following steps:

Imgur

Once you have imported base app, go ahead and run it, and you should see the following output :

Imgur

Let's understand the steps involved in creating this app. And after that you will go ahead and create different themes in a similar fashion.

1. We created a new app called ThemeSwitcher and main activity called ThemeActivity.

2. Then we created a simple layout on which we'll be applying all our styles and themes to.

3. Created custom attributes by following custom attributes guide. These are the custom attributes that our theme will define.

4. Created dimens.xml. This is the XML resource that carries dimension values for padding, mergins etc. Any new values should be added to this file.

5. Defined custom styles for our relative layout, button, textview and spinner. Also defined drawables for various button states, background image etc. by referring create custom styles and drawables guide.

6. Created themes.xml file to define the theme attributes by following creating theme.xml file. Any new themes will be added to this file by following similar pattern.

7. After this, we applied the custom styles to views in our layout file. Refer apply custom styles guide.

8. Now we run the app and we get the output shown above.

Tasks for this exercise :

1. Create Multiple Themes

2. Apply Dynamic Themes

3. Test your app


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.