Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.

Release API Apache 2


AndroidHeatMap is an easy to use heat map control for Android apps.

Example View


There are three different ways to use this library:

1. Gradle dependency (recommended)

  • Add the following to your project level build.gradle:
allprojects {
	repositories {
		maven { url "" }
  • Add this to your app build.gradle:
dependencies {
	implementation 'ca.heartlandsoftware:androidheatmap:1.2.0'

2. Maven

  • Add the following to the <repositories> section of your pom.xml:
  • Add the following to the <dependencies> section of your pom.xml:

3. Clone the whole repository

  • Open your commandline-input and navigate to the desired destination folder on your machine (where you want to place the library)
  • Use the command git clone to download the full AndroidHeatMap repository to your computer (this includes the folder of the library as well as the folder of the example project)
  • Import the library folder (AndroidHeatMap) into Android Studio (recommended) or your Eclipse workspace
  • Add it as a reference to your project:

Getting Started

Add a HeatMap control to your xml layout.

    app:maxOpacity="255" />

Back in your activity or fragment you would get a reference to the BottomSheetLayout like any other view.

HeatMap heatMap = (HeatMap) findViewById(;

Set the range that you want the heat maps gradient to cover.


Now you can add data to the heat map.

//add random data to the map
Random rand = new Random();
for (int i = 0; i < 20; i++) {
    HeatMap.DataPoint point = new HeatMap.DataPoint(rand.nextFloat(), rand.nextFloat(), rand.nextDouble() * 100.0);


Colour Gradient

Changing the colour gradient.

//make the colour gradient from pink to yellow
Map<Float, Integer> colorStops = new ArrayMap<>();
colors.put(0.0f, 0xffee42f4);
colors.put(1.0f, 0xffeef442);


Set the minimum and maximum opacity of the heat map. The value is an 2 byte alpha value with the range [0,255].

//make the minimum opacity completely transparent
//make the maximum opacity 50% transparent

Or set it in xml.

    app:maxOpacity="255" />


Set the radius of each points coloured gradient.

//set the radius to 300 pixels.

Or in xml.

    app:radius="100dp" />

HeatMap Size

If you are seeing OutOfMemoryError thrown on some devices this can be used to reduce the size of the bitmap that the HeatMap is rendered on to reduce memory usage.

//set the maximum width to 400px

Or in xml.

    app:maxDrawingWidth="200dp" />

Draw Data Markers

Markers can be drawn on the HeatMap to indicate where the data points are located. The markers are drawn in a callback to allow any app to decide how the marker should be drawn. An example callback is included that draws a simple circle at the data point.

//draw a dark violet circle at the location of each data point
heatMap.setMarkerCallback(new HeatMapMarkerCallback.CircleHeatMapMarker(0xff9400D3));


After changing an option after the heat map has been rendered force a refresh.



Copyright 2020 Heartland Software Solutions Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.