-
Notifications
You must be signed in to change notification settings - Fork 34
Basic HoloAccent setup
This document explains the steps to use HoloAccent on your project. Remember that this is only valid for projects with a minimum SDK version of 14 (Ice Cream Sandwich 4.0) or higher. It is also a basic setup, more advanced topics are discussed in other documents.
Add the project to your workspace through "File > New > Project..." and select "Android Project From Existing Source" find the HoloAccent directory and accept. Then, right click on your project and select "Properties", there go to the "Android" section. Then, press "Add..." and select HoloAccent from the list.
HoloAccent is available on Maven Central, so you can just add the dependency to your build.gradle file:
dependencies {
repositories {
mavenCentral()
}
compile 'com.negusoft.holoaccent:library:1.1'
}
Add the following dependency:
<dependency>
<groupId>com.negusoft.holoaccent</groupId>
<artifactId>library</artifactId>
<version>1.0.1</version>
<type>apklib</type>
</dependency>
First, you have to decide what theme to use. Each HoloAccent theme corresponds to a default Holo theme:
- Theme.Holo > Theme.HoloAccent
- Theme.Holo.Light > Theme.HoloAccent.Light
- Theme.Holo.Light.DarkActionBar > Theme.HoloAccent.Light.DarkActionBar
*There are other ColoredActionBar themes available. This is further explained in another wiki page.
Create a "styles.xml" file under the "res/values" directory. There we create the style that we will apply as a theme. For example this will be the content of the file with red accent color based on the Theme.HoloAccent.Light theme:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.HoloAccent.Light">
<item name="accentColor">#ff0000</item>
</style>
</resources>Note that we set the color with the accentColor attribute. If you want to use another color just change this value.
Simply apply the theme to your application like this:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
...
</application>
You have to extend the AccentActivity class in stead of activity. For example:
public class MyActivity extends AccentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}You have do this for EVERY ACTIVITY in your app.
You are now ready to run the app. Remember, to change the accent color, just change the value in styles.xml and rebuild the app to see the result.