changing default start value for seekbar in android - android

the default start value for seekbar is 0. Is it possible to change that value to 10? Please explain me how to set the value.
Thanks in advance.

change from XML : to change default value of seekbar use android:progress="" property of seekbar
android:progress="10"
android:max="100"
change from Java : to change default value of seekbar use setProgress(int progress) method
yourSeekbar.setProgress(10);

So I've been trying to do the same thing only for an arc progress bar. The way that I managed to achieve my desired results was by manipulating my .setProgress and .setMax values.
If you want to start at 10 and have a max of 100, your code should follow something like this:
progressBar.setProgress(_______-10);
progressBar.setMax(90);
For setProgress it should be the number you want minus 10.. this way if you have 10, then the calculation (10-10) would give you 0 which will not move your progress bar.
For setMax.. the reason why you need to subtract 10 is because if you put 100 as your max and say the progress is (100-90).. it will give you 90 (your max)... in other words if we weren't doing any calculations for setProgress, then your setMax should remain the same, but since we did a calculation for setProgress, you have to do the same calculation for your set max.

You can set it via xml, i dont know if you still need this but here is the answer:
android:min="10000" android:max="100000" android:progress="5000"

Related

How to show value from negative to positive in mpandroid barchart?

I'm using mpandroid barchart and I have set negative and positive value in it but I want to that in barchart values start from -100 to 0 and 0 to 10, 20 etc.
Not sure if this will help your issue, but try setAxisMinimum().
Also note, as per the documentation:
Do not forget to call setStartAtZero(false) if you use this method. Otherwise, the axis-minimum value will still be forced to 0.

MPAndroidChart how to make y-axis to start at non-zero value?

I am using MPAndroidChart library and have a set of data entries where the Y values are between 20 - 30 and I'm currently displaying it in a Line chart. However, I notice that there is a big gap because the Y-axis starts at 0 instead of 20.
How can I make Y-axis to start at the 20 instead of 0? Or even better the minimum of all y-values?
Thank you for your time!
You can find this in the documentation.
yAxis.setAxisMinValue(...)
allows you to adjust the lower limit of the axis to your needs.
The last version includes a left and right axis. You can set to zero like this (Kotlin):
chart.axisLeft.axisMinimum = 0f
chart.axisRight.axisMinimum = 0f
You can set zero in Bar Graph like this in Java
barChart.getAxisLeft().setAxisMinValue(0f);
barChart.getAxisRight().setAxisMinValue(0f);

Android Auto Font Resizer

I am working on Android textview,case is i have a specific height of textview,i want to adjust the text in the given textview height by adjusting the font size.If a text is of 10 charachers it will covers the whole height and if text is off 400 characters it will decreases the font to adjust in height of textview. I have tried auto text resize class but it does not getting the desire result.
You are looking for FontFit TextView. Check out here.
You just have to use it instaed of normal TextView like this..
TextView tv = new FontFitTextView(context);
Hope this helps
You can also write your own logic for that like
1- : Count no or character in side text watcher
2- : if no of character more then 10 then reduce the size of test using textsize method.
3- : the same logic if character more then 10 then reduce the size of test using textsize method.
or you can also put it on loop then i think you can achieve it also.

Android XYPlot set width of line, size of point and disable legend

I'm trying to change width of line in XYPlot and size of point, any suggestion?
And another question - how i disable legend to SimpleXYSeries? Set to null cause Error.
I'm trying to change width of line in XYPlot and size of point. Any suggestion?
As shown here, you can alter the line thickness using either setSeriesStroke() or setBaseStroke() in your chosen renderer. Assuming XYLineAndShapeRenderer, you can change the rendered Shape using the approach shown here.
How I disable the legend?
You can pass false for the legend parameter to your chosen ChartFactory method or JFreeChart constructor.

Unable to programmatically change width of horizontal progressbar

I would like change the width of a Horizontal Progressbar programmatically (initial size is set in XML using RelativeLayout...but I would like to dynamically change it based on certain values).
I have tried setMinimumWidth(50) in my code, but that did not make a difference. I have also tried setting 'android:layout_width="wrap_content", but that did not work either.
Here is my XML:
<ProgressBar android:id="#+id/progress_horizontal"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="100dip"
android:layout_height="wrap_content"
/>
Thanks in advance for any assistance!
What layout is your ProgressBar in? This makes a difference as to how the layout_width and height are interpreted.
However, I think you are seeing a conflict between the View's width, and the layout_width. Each time the view is rendered, its preferred size is determined based on the minWidth, width, etc. set on it. The layout that the view sits in can then update the actual size to render based on the layout_width information. See How Android Draws Views and View size documentation for more info on the two phase process.
In your case, you have the layout_width set to 100, and the minimum width set to 50, so I would think it would always show 100.
Try setting the layout_width to wrap_content, and then updated the preferred width for the ProgressBar.
I would imagine the setmindwidth would be met when you give it an initial value of 100. the system would receognize it exceeds 50 and then continue to do as the rest of what it's told. try making the min width 150, set the xml for an initial value of 75 and in your onCreate fire off a Log.d("progbar", String.valueOf(myprogress.width));
disclaimer - written when in front of work computer without development environment for reference.

Categories

Resources