oli107 / material-range-bar Goto Github PK
View Code? Open in Web Editor NEWAndroid widget for selecting a range of values.
License: Apache License 2.0
Android widget for selecting a range of values.
License: Apache License 2.0
I can't find the @dimens in the file
https://github.com/oli107/material-range-bar/blob/master/RangeBarSample/res/drawable/material_button.xml
setFormatter is not called in createPins
Example :
For first tick left pin is jumping by 600 and after that it is jumping by 100.
What's the issue?
<com.appyvet.rangebar.RangeBar xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/rbPrice"
android:layout_width="match_parent"
android:layout_height="72dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
custom:tickEnd="4000"
custom:tickHeight="0sp"
custom:tickInterval="100"
custom:tickStart="600" />
Full Code:-
<TextView
android:id="@+id/tvMinPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="₹ 600"
android:textColor="@color/black" />
<com.appyvet.rangebar.RangeBar xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/rbPrice"
android:layout_width="match_parent"
android:layout_height="72dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@+id/tvMaxPrice"
android:layout_toRightOf="@+id/tvMinPrice"
custom:connectingLineColor="@color/colorAccent"
custom:pinColor="@color/colorAccent"
custom:rangeBarColor="@color/colorAccent"
custom:selectorColor="@color/colorAccent"
custom:tickColor="@color/colorAccent"
custom:tickEnd="4000"
custom:tickHeight="0sp"
custom:tickInterval="100"
custom:tickStart="600" />
<TextView
android:id="@+id/tvMaxPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="₹ 4000"
android:textColor="@color/black" />
</RelativeLayout>
Wiki states that :
custom:thumbRadius / setThumbRadius(dim) can be used for thumb radius customisation and
custom:thumbColorNormal / setThumbColorNormal(int) can be used for thumb colour customisation
But I am unable to set any of these from XML or Java code.
I looked into the attrs.xml file in res/values, it doesn't even have these attributes. Neither does the RangeBar class have the stated methods.
Hi,
I'm using the rangeBar with a single value. I have a bar with 24 indexes and whenever the pin crosses the index 3 the application throws a NullPointerException. Anyone having the same problem?
I already try to play with some xml properties but I still have the problem.
Below is my xml code:
<com.appyvet.rangebar.RangeBar
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/slider"
android:layout_width="wrap_content"
android:layout_height="64dp"
custom:tickStart="0"
custom:tickInterval="1"
custom:tickEnd="24"
custom:pinColor="#ec3852"
custom:pinRadius="10dp"
custom:selectorColor="#ec3852"
custom:tickColor="#00ffffff"
custom:selectorSize="4dp"
custom:connectingLineColor="#ec3852"
custom:connectingLineWeight="1dp"
custom:pinMaxFont="10sp"
custom:barWeight="1dp"
custom:rangeBar="false"
android:layout_alignTop="@+id/search_radius"
android:layout_alignEnd="@+id/slider2"
android:layout_toEndOf="@+id/auto"
android:layout_alignStart="@+id/slider2"
android:layout_marginTop="8dp" />
custom:temporaryPins="false"
I switch rangeBars enabled property with this: mRangeBar.setEnabled(enable);
Setting it false makes pins invisible (I think it should only set the color gray). Switching it back to enabled doesn't make the pins visible again.
When temporaryPins set to true, it works as intended.
how can id disable bubble float of range bar? i just want sometimes to use without float bubble
On some devices I get crashes like this:
Fatal Exception: java.lang.IllegalArgumentException: Pin value left 0.0, or right 120.0 is out of bounds. Check that it is greater than the minimum (0.0) and less than the maximum value (100.0)
How can I avoid this? Because when I test it on all my devices that I have I never get that exception? I can't see how they can slide so far to the right that it goes over the max because the UI doesn't let you do that?
When we go fast to the left with the left pin, the pin becomes negative sometimes. How to fix that ?
My rangebar with constant pin (not the tmeporary one) and only right pin behaves badly when rangebar.setRangePinsByIndices(0, 3);
is called. I managed to reproduce it on the sample app. The thing is it only reproduces when setRangePinsByIndices
is called after some time like this:
rangebar.postDelayed(new Runnable() {
@Override
public void run() {
rangebar.setRangePinsByIndices(0, 3);
}
}, 2000);
It's a simple sample but it behaves the same way when threading with rxjava and probably anything else.
I made a branch demonstrating that on my fork: https://github.com/jkwiecien/material-range-bar/tree/pin-disappear
Since all the methods like setTickStart(), setTickEnd(), setTickInterval(),setRangePinsByValue() and the others all take float values, when the range is large the numbers loose precision and hence loose data.
Please take note on this issue
There is getter for get pin value but no setter for set left & right pin value.
I have noticed when the rangebar is aligned by component to the left of another view the left hand pin freezes when dragged until a certain distance is reached. It seems to "snap" to a certain index then "snap" back. Here is a video of it https://youtu.be/R0Q7NwYOskg.
As you can see as well clicks also do not work within the non functioning range.
Here is the setup for that video. Its a starter project with the following activity main.
<TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"/>
<com.appyvet.rangebar.RangeBar
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/waveDirectionRangebar"
android:layout_width="250dp"
android:layout_height="72dp"
custom:tickStart="1"
custom:tickInterval="1"
custom:tickEnd="17"
custom:connectingLineColor="#2196F3"
custom:tickColor="#FFEBEE"
custom:selectorColor="#FFEBEE"
custom:pinColor="#F44336"
custom:pinPadding="10dp"
custom:rangeBarColor="#F44336"
custom:pinMaxFont="12dp"
custom:pinMinFont="12dp"
android:layout_below="@+id/textView"
android:layout_toRightOf="@+id/textView"
android:layout_toEndOf="@+id/textView"/>
Can we consider an enhancement to show start and end labels at the far right and far left?
Nothing works properly, values are donated when I am getting left/right index also it goes out of range if you move it to the end couple of times also it not support setRangePinsByIndices(x,y) properly... in one word - it' a big bit SHIT!
Problem is there
if (pinRadiusDP == -1) {
mPinRadiusPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
DEFAULT_THUMB_RADIUS_DP,
mRes.getDisplayMetrics());
} else {
mPinRadiusPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
->> pinRadiusDP,
mRes.getDisplayMetrics());
}
pinRadiusDP == 0..0
soo its not going to the first condition.. and setting pinRadius to 0.0 DP so pins are invisible.
FAST SOLUTION:
change the dp value
if (pinRadiusDP == -1) {
mPinRadiusPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
DEFAULT_THUMB_RADIUS_DP,
mRes.getDisplayMetrics());
} else {
mPinRadiusPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
-->> DEFAULT_THUMB_RADIUS_DP,
mRes.getDisplayMetrics());
}
but if You will update this library to new version change the condition
I included this library in my project which already had a style AppTheme and AppBaseTheme defined. This caused an issue where the AppCompatBase theme from the library is used from the libraries values-v11/styles.xml instead of the AppCompatBase theme from my values/styles.xml.
When range is very large number like a million, it becomes skipping frames.
Left slider : 1-12
Right Slider : 00:59
In this way, can implement this slider for time.
Hello, please fix bug in RangeBar.onTouchEvent, line #433.
Current version:
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
this.getParent().requestDisallowInterceptTouchEvent(false);
onActionUp(event.getX(), event.getY());
return true;
Replace with:
case MotionEvent.ACTION_UP:
this.getParent().requestDisallowInterceptTouchEvent(false);
onActionUp(event.getX(), event.getY());
return true;
case MotionEvent.ACTION_CANCEL:
this.getParent().requestDisallowInterceptTouchEvent(false);
return false;
These changes fix scrolling issue (unprompted rangebar changes) when RangebBar is in scrollable view.
Hello, I'd like to know if exists a way to can add listeners when starts drag and finish because I need this data to save in remove database and doing it every time is dragging is very heavy.
Thanks.
I want to send something to a server when I stop touching the rangebar, i.e do the same thing as onStopTrackingTouch() in the Android SeekBar. The only way I've found of doing this is to use an onTouchListener and check MotionEvent.ACTION_UP, but then the view of the RangeBar does not update until I release my finger.
I can't use onRangeBarChangeListener() for this, as I don't want to be sending information to the server on every change.
Is there any easy way of doing this? :)
Thanks in advance!
I have a request : always show the pins with values, even when user don't drag it. (poke @jkwiecien who have made a good work with temporaryPins)
The issue is the attributes have a general name like "textColor" which other libraries use and prevent the build to be succesful.
How hide buble with value and poin selector NOT range ??
When onRestoreInstanceState of the view is called, the thumbs become invisible. I think that's because createPins method is called, and it creates thumbs with 0 radius pans.
mRightThumb
.init(ctx, yPos, 0, mPinColor, mTextColor, mCircleSize, mCircleColor, mMinPinFont,
mMaxPinFont, false);
Please fix it.
It would be a nice feature to allow the user to define what the maximum and minimum Pint texts font size. I have noticed that when a Pins text contains 2 characters the font size shrinks. I believe it would be more aesthetic if the font size was the same throughout and let the user decide.
It seems as though if you let the user change
mMinPinFont
https://github.com/oli107/material-range-bar/blob/master/rangebar/src/com/appyvet/rangebar/PinView.java#L88
and
mMaxPinFont
https://github.com/oli107/material-range-bar/blob/master/rangebar/src/com/appyvet/rangebar/PinView.java#L90
It would allow the user to define the right size that works for them.
Or implement a variable that if set, sets the font size of the text.
I get this crash report from a Android 5.1 device (Xperia ZR). I think it's a problem with onRestoreInstanceState in Fragments. Any ideas?
java.lang.IllegalArgumentException: Pin index left 0, or right 31 is out of bounds. Check that it is greater than the minimum (100.0) and less than the maximum value (250.0)
at com.appyvet.rangebar.RangeBar.setRangePinsByIndices(RangeBar.java)
setRangePinsByValue(RangeBar.java)
rangeBarInit(RangeBar.java)
createBar(RangeBar.java)
isValidTickCount(RangeBar.java)
onActionMove(RangeBar.java)
pressPin(RangeBar.java)
movePin(RangeBar.java)
access$002(RangeBar.java)
access$000(RangeBar.java)
at com.appyvet.rangebar.RangeBar.onRestoreInstanceState(RangeBar.java)
at android.view.View.dispatchRestoreInstanceState(View.java:13823)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2894)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2894)
at android.view.View.restoreHierarchyState(View.java:13801)
at android.support.v4.app.Fragment.restoreViewState(Fragment.java)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManagerImpl.java)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java)
at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java)
at android.support.v4.view.ViewPager.populate(ViewPager.java)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java)
at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java)
at com.astuetz.PagerSlidingTabStrip$2.onClick(PagerSlidingTabStrip.java)
at android.view.View.performClick(View.java:4856)
at android.view.View$PerformClick.run(View.java:19956)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5389)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
custom:barColor = "#ffffff"
gives error "No resource identifier found for attribute 'barColor' in package 'com.example.android'
I recently imported this library into my project, however the color of the range bar does not match the rest of my application?
I know i'm being picky now, but I really feel that by default the library should look at the accent and primary colors of the app, so it can be even more material design compatible.
<color name="colorPrimaryDark">#01B169</color>
<color name="colorPrimary">#78D64B</color>
<color name="colorAccent">#2CD5C4</color>
If u will disable RangeBar Mode
isRangeBar = false
Visible thumb on seekbar moving only when u do something like drag and drog..
It should also moving like in RangeBar Mode ( click on the axis x Value and thumb moving to this value).
FAST SOLUTION:
private void onActionMove(float x) {
// Move the pressed thumb to the new x-position.
if (mIsRangeBar && mLeftThumb.isPressed()) {
movePin(mLeftThumb, x);
} else if (mRightThumb.isPressed()) {
movePin(mRightThumb, x);
** add This condition to onActionMove**
} else if ( mIsRangeBar == false){
movePin(mRightThumb, x);
}
Is there anyway to stop the bubble text from getting bigger as it goes from smaller to bigger numbers, and v.v.? I really think it's just ugly to scale the size of the text and not making it constant.
Also, is there anyway to set the typeface, style, etc. of the bubble text? I find this library so helpful if only not on these issues. Thanks.
The pin text gets cut off at the top when the text is any character between 0 - 9. It seems to work with characters of 2 digits due to the calibrateTextSize method.
When I set a large tickEnd, for example tickEnd 9999 and tickStart 100 the rangebar reacts very slow.
Let the user use two fingers to adjust the range at once. I use it as UI to trim a video. This way he could use kind of a shrink gesture.
At this moment one can only adjust one selector at a time.
Is possible to disable moving one pin to position where is second pin? Now user can set the same value for left and right pin and then it looks like there is only one pin. If I do condition in listener it do not looks good.
Hello!
Why you need this text formatter?
private PinTextFormatter mPinTextFormatter = new PinTextFormatter() { @Override public String getText(String value) { if (value.length() > 4) { return value.substring(0, 4); } else { return value; } } };
Have some corresponding issues.
I want to set the value for range bar is between 0-100000. The maximum value is set as 1000 after 9999. Below is my xml file.
<com.appyvet.rangebar.RangeBar
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="72dp"
android:id="@+id/priceRangeBar"
custom:tickStart="0"
custom:tickInterval="5000"
custom:tickEnd="100000"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_centerHorizontal="true"/>
attribute "texcolor " has been defined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.