diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/1.png b/1.png
new file mode 100755
index 0000000..fe90ba1
Binary files /dev/null and b/1.png differ
diff --git a/2.png b/2.png
new file mode 100755
index 0000000..424f0f3
Binary files /dev/null and b/2.png differ
diff --git a/3.png b/3.png
new file mode 100755
index 0000000..5554ab4
Binary files /dev/null and b/3.png differ
diff --git a/README.md b/README.md
index 5b74f3a..1f06bfa 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ This library allows you to show a set of data over a horizontal bar. Just like t
-
+
@@ -77,6 +77,8 @@ dependencies {
android:layout_height="12dp" />
```
+
+
The view by default, will have a grey colored background and round corners. In order to customize it, you can use the attributes listed on the table below:
#### Optional customizations
@@ -110,9 +112,9 @@ The `addData()` arguments:
- **dataId** - An arbitrary id, so you can query it's information later, such as it's percentage via the `getDataPercentage()` method.
-- **percentage** - How much of the bar this data will fill, starting from the last added data. The total percentage of the added data *should not exceed 100%*. E.g: `float 42F | int 42`
+- **percentage** - How much of the bar this data will fill, starting from the last added data. The total percentage of the added data *should not exceed 100%*. E.g: *`float 42F | int 42`.*
-- **colorRes** - the background color of this new detail. E.g: `getResources().getColor(R.color.blue)`;
+- **colorRes** - the background color of this new detail. E.g: *I recommend using these two methods for retrieving the colors: `ContextCompat.getColor(getContext(), R.color.blue)` or `getResources().getColor()`.*
:egg:Example:
@@ -123,11 +125,11 @@ HorizontalBarChartView hbcv = findViewById(R.id.hbcv);
// Add the data.
int percent = 12;
-int color = getResources().getColor(R.color.blue);
+int color = ContextCompat.getColor(getContext(), R.color.blue);
hbcv.addData(MEDIA_ID, percent, color);
int percent = 35;
-int color = getResources().getColor(R.color.green);
+int color = ContextCompat.getColor(getContext(), R.color.green);
hbcv.addData(APPS_ID, percent, color);
...
@@ -135,7 +137,9 @@ hbcv.addData(APPS_ID, percent, color);
sdv.show();
```
-
+
+
+
##### 2. Getter methods
diff --git a/app/build.gradle b/app/build.gradle
index 457fecd..46d6c65 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -21,7 +21,6 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
- implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
diff --git a/app/src/main/java/com/kishannareshpal/horizontalbarchartview/MainActivity.java b/app/src/main/java/com/kishannareshpal/horizontalbarchartview/MainActivity.java
index 772f01a..0a5131e 100644
--- a/app/src/main/java/com/kishannareshpal/horizontalbarchartview/MainActivity.java
+++ b/app/src/main/java/com/kishannareshpal/horizontalbarchartview/MainActivity.java
@@ -1,5 +1,8 @@
package com.kishannareshpal.horizontalbarchartview;
+import android.content.Context;
+import android.os.Build;
+import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
@@ -12,13 +15,17 @@ public class MainActivity extends AppCompatActivity {
private static final int MAIL_DETAILID = 3;
private static final int OTHERS_DETAILID = 4;
-
+ // Utils
+ private Context ctx;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
+ // Init utils
+ ctx = this;
+
// Init the component
final HorizontalBarChartView hbcv = findViewById(R.id.sdv_details);
Button btn = findViewById(R.id.button);
@@ -27,10 +34,10 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onClick(View v) {
// Add as many details as you'd like...
- hbcv.addData(APPS_DETAILID, 12, getResources().getColor(R.color.red));
- hbcv.addData(MEDIA_DETAILID, 14, getResources().getColor(R.color.yellow));
- hbcv.addData(MAIL_DETAILID, 5, getResources().getColor(R.color.blue));
- hbcv.addData(OTHERS_DETAILID, 42, getResources().getColor(R.color.grey));
+ hbcv.addData(APPS_DETAILID, 12, ContextCompat.getColor(ctx, R.color.red));
+ hbcv.addData(MEDIA_DETAILID, 23, ContextCompat.getColor(ctx, R.color.yellow));
+ hbcv.addData(MAIL_DETAILID, 17, ContextCompat.getColor(ctx, R.color.blue));
+ hbcv.addData(OTHERS_DETAILID, 42, ContextCompat.getColor(ctx, R.color.green));
// ...
// Call .show() to draw the details on the view.
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 166f326..a924175 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -40,10 +40,10 @@
+ android:textStyle="bold"
+ android:textColor="@color/red"
+ android:text="Apps" />