Android Progress Circle With Multiple Colors - android

I'm trying to draw a indeterminate (circular) progress bar that is white and then fades into purple.
This is my ProgressBar:
<ProgressBar
android:id="#+id/mainProgressBar"
style="#style/Widget.AppCompat.ProgressBar"
android:layout_width="#dimen/progressbar_size"
android:layout_height="#dimen/progressbar_size"
android:layout_gravity="center" />
Then I paint it white:
mainProgressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
Do I need add another ColorFilter? Set a style or theme on the progressbar? No idea what to do here.

DonutProgressView is a configurable doughnut-like graph view capable of displaying multiple datasets with assignable colors. It supports animations and features a gap at the top, which makes it look like a gauge (or tasty bitten-off donut - that's why the name).
Click Here to See Git Lib

Related

Show Circular progress bar on android (filled circle)

How to show a filled circular progress bar on android?
The progress bar should be filled like a circle not like a ring and it should have customizable features like animation timings animation interpolators etc.
This project helps display a simple filled circular progress bar on android 5 (lolipop) and above.
It is extremely customizable all the custom attributes are shown in the code sample below.
This is an open source project, feel free to look into code or clone it and modify it per your requirements.
Follow the GitHub instructions to get started
<com.jeet.circularprogressbar.CircularProgressBar
android:id="#+id/customRoundProgressBar"
android:layout_width="100dp"
android:layout_height="100dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:maxProgressLimit="60"
app:progress="50"
app:maxAnimationDuration="2500"
app:animationInterpolator="AccelerateDecelerateInterpolator"
app:showProgressText="true"
app:progressTextSize="16sp"
app:progressTextColor="#color/black"
app:progressBarColor="#android:color/holo_red_dark" />
Max progress limit by default is 100 and min progress limit by default is 0, none of the parameters are required other than width and height.
You can play with different interpolators to animate the progress values, **default is acceleratedecelateinterpolator**
The maximum Animation Duration can also be changed.
All the properties shown in xml can be changed from code as well
For example:
setProgress(progressValue)
can be called from code to set the current progress of the progress bar.
Result

MPAndroidChart white Background

I am using the MPAndroidChart library. I am setting the multi line chart with data using MPAndroidChart. It's working great but the background is coming white. This is what i am doing
nhChart = new LineChart(getActivity());
nhChart.setDescription("Number of Hits View");
nhChart = (LineChart) hitsView.findViewById(R.id.line_chart_number_of_hits);
//int color = Color.parseColor("#80101010");
nhChart.setBackgroundColor(Color.parseColor("#80101010"));
//nhChart.setBackgroundResource(R.drawable.background_portrate);
//nhChart.setBackground(getResources().getDrawable(R.drawable.background_portrate));
nhChart.setStartAtZero(true);
nhChart.setDrawBorder(true);
nhChart.setNoDataTextDescription("No Data available for Charts");
nhChart.setDrawYValues(false);
nhChart.setDrawBorder(true);
nhChart.setScaleEnabled(true);
nhChart.setHighlightEnabled(false);
nhChart.setTouchEnabled(true);
//nhChart.setGridColor(Color.WHITE & 0x70FFFFFF);
//nhChart.setDragScaleEnabled(true);
nhChart.setPinchZoom(true);
setData(valueDate.size(),10000);
nhChart.animateX(2500);
Legend l = nhChart.getLegend();
l.setForm(LegendForm.CIRCLE);
l.setFormSize(6f);
l.setTextColor(Color.WHITE);
YLabels y = nhChart.getYLabels();
y.setTextColor(Color.WHITE);
y.setLabelCount(6);
XLabels x1 = nhChart.getXLabels();
x1.setCenterXLabelText(true);
x1.setPosition(XLabelPosition.BOTTOM);
x1.setTextColor(Color.WHITE);
I am plotting line graphs in post execute method of AsyncTask in a fragment viewpager. Other fragment showing the graph shows the same white background. I tried setting a color for the background but nothing works. I also left it blank, but its still showing me the white background. I also updated the latest Jar but its not works. Please help.
Here is the image how it looks
You want this for transparent:
chart.setDrawGridBackground(false);
And this for transparent bar:
chart.setDrawBarShadow(false);
Well by default, the backgroud of the chart is transparent which means that it will have whatever color you set for the view/layout below the chart.
If you want to change the background (color, or maybe drawable), you can do that in the following ways:
in .xml (android:background="...")
--> set the background color of the chart in xml or set the backgroud color of the layout the chart is in.
by calling setBackgroundColor(...) or setBackgroundResource(...)
I guess you want your background to be some kind of black?
What happens if you call:
chart.setBackgroundColor(Color.BLACK)?
Does setting the background-color work then? Also check the example code in the github repo here. There are some cases in the example app that change the background color.
You can do this with:
chart.setBackgroundColor(getResources().getColor(R.color.transparent));
Please define first:
<color name="transparent">#00000000</color>

How to change chart background with MPAndroidChart library?

I'm using the amazing library MPAndroidChart. It works like a charm, except when I'm trying to change the background color of the BarData. Default color is white, and I want to change it to Transparent.
I've tried this :
Paint p1 = mChart.getPaint(Chart.PAINT_GRID_BACKGROUND);
p1.setColor(Color.RED);
and this:
<com.github.mikephil.charting.charts.BarChart
android:id="#+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"/>
... but it seems that doesnt works.
Any ideas ?
Thanks =)
Since release v1.6.5, the background of the Chart is transparent by default. Meaning, that everything in the background (chart background, other Views, etc.) that is not overlayed by data drawn into the Chart, will be visible.
If you want to change the background (color, or maybe drawable), you can either do that by changing the chart-background
in .xml (android:background="...")
by calling setBackgroundColor(...) or setBackgroundResource(...)
Another way could be to change the background of the parent layout that contains the Chart.
Code to change Background color:
chart.setBackgroundColor(Color.TRANSPARENT); //set whatever color you prefer
chart.setDrawGridBackground(false);// this is a must
if you want to Change Whole Screen Background Color
Barchart chart;
chart.setBackgroundColor(Color.rgb(0, 0, 0));//Set as a black
chart.setDrawGridBackground(false);//set this to true to draw the grid background, false if not
Happy to help Thanks
So, after some research, I've found that it's not possible yet: https://github.com/PhilJay/MPAndroidChart/issues/53
Hope It will be possible soon ! =)

Making a android button’s background translucent,

Is there a way to make an android button’s background translucent within xml code,
So the button has no background drawable?
android:background="#android:color/transparent"
You can also set your own colors:
android:background="#80000000"
The first two hex characters represent opacity. So #00000000 would be fully transparent. #80000000 would be 50% transparent. #FF000000 is opaque.
The other six values are the color itself. #80FF8080 is a color I just made up and is a translucent sort of pinkish.
The best way is to create a selector.
Set the background to the standard android transparent color.
In Code:
myButton.setBackground(getResources().getColor(android.R.color.transparent));
In xml:
android:background="#android:color/transparent"

Android: Custom horizontal progress bar

Im trying tu customize horizontal progress bar in my application. I want it to have sharp corners (no radius) and blue color (not default yellow or a mix of colors, so I also dont want to be using gradient). The reason Im mentioning these two things is that in every example code I found, the progress bar color was being changed into a color mixture using gradient instead of a simple color. For example in this post:
How to change progress bar's progress color in Android
I was trying to modify this code but with no luck. My question is what is the meaning of the three sections of the code in the answer to the question I linked above? I mean the
#android:id/background
#android:id/secondaryProgress
#android:id/progress
Also when I was trying to get some help from the Eclipse using ctrl+space, it couldnt give me any because the content assist wasnt available at that location. I only want my progress bar to change to a simple color and not to have rounded corners.
Thanks!
I stole the answer from your link. Something like that should work for you:
<!-- this is the Background Shape of the ProgressBar -->
<item android:id="#android:id/background">
<shape>
<!-- you don't want round edges, so I removed it here.
We dont even need a gradient, replace it with solid -->
<solid
android:color="Your bg color" />
</shape>
</item>
You can edit the other accordingly, where progress is usually a yellow overlay and secondary a grey shadow over the yellow overlay.
Read this documentation for further reference
You should also include tags above shape for progress. Otherwise, progressbar will always show full.
Discovered here after a big headache: http://www.tiemenschut.com/how-to-customize-android-progress-bars/
Hope this helps somebody.

Categories

Resources