GithubHelp home page GithubHelp logo

material-range-bar's Introduction

Android Arsenal

MaterialRangeBar

MaterialRangeBar is a fork from https://github.com/edmodo/range-bar that adds some basic material styling, as well as start and end values, values as floats and some other things. It is aiming to mimic this:

http://www.google.com/design/spec/components/sliders.html

It is similar to an enhanced SeekBar widget, though it doesn't make use of the SeekBar. It provides for the selection of a range of values as well as for a single value. The selectable range values are discrete values designated by tick marks; the pin (handle) will snap to the nearest tick mark. This is my first library project, apologies for poor coding, etc etc.

Supported on API Level 12 and above for animations.

Img

Change Log

1.4.8 - Added mrb_minThumbDistance for specifying distances between 2 thumbs. All the selector properties are renamed to thumb.
1.4.7 - Fixed selector boundary cut-off issue
1.4.6 - Added tick colors, Added Left,Right and Default Selector Color. Added Touch Started /Touch Ended events to Rangebar. Fixed rangebar so that it behaves correctly inside scrollview. Also fixed Selected Tick label color issue.
1.4.5 - Added TOP and BOTTOM tick labels properties and drag only option. Also updated Gradle and screenshots.
1.4.4 - Added List of colors for connecting line and fix pins invisibility issue.
1.4.3 - Fixes an issue where you user was able to drag a thumb outside of the valid range of Rangebar.
1.4.2 - Added option for rounding status Bar progress using mrb_rangeBar_rounded. Also Implemented seekbar to select the nearest tick, when clicked. Also Fixed Rangebar issue that was causing right pin to move left of left pin when both had same value.
1.4.1 - Small Ui fixes
1.4 - Added mrb_ prefix to all attributes. Also added mrb_selectorBoundaryColor and mrb_selectorBoundarySize attribute.  
1.3 - Stopped pins appearing on initialisation when temporary. Margin correct even if pin radius = 0. PR to correct motion down
1.2 - NPE fixed for movePin
1.1 - Merged pull requests
1.0 - Merged pull requests to fix range bar issues and issues in scrollview, promoted to 1.0 release due to few other PRs.
0.1 - released onto Maven Central. Fixed color pickers in sample. Added ability to set pin color via XML and pin text color via XML or programatically
0.0.1 - 0.0.7 - Initial releases.

Developers can customize the following attributes (both via XML and programatically)

Tick Properties

mrb_tickStart | float
mrb_tickEnd | float
mrb_tickInterval | float
mrb_tickHeight | dimension
mrb_tickDefaultColor | color
mrb_tickColors  | reference (array of hex colors)

Tick Label Properties

mrb_tickLabelColor | reference or color         // Unselected label color
mrb_tickLabelSelectedColor | reference or color         // Selected Label Color
mrb_tickTopLabels | reference (String array)
mrb_tickBottomLabels | reference (String array)
mrb_tickDefaultLabel | reference or string          // Used in cases when top/bottom labels are not equal to number of ticks
mrb_tickLabelSize | dimension (sp)

Bar Properties

mrb_rangeBar | boolean
mrb_barWeight | dimension
mrb_rangeBarColor | reference or color
mrb_rangeBarPaddingBottom | dimension
mrb_rangeBar_rounded | boolean
mrb_connectingLineWeight | dimension
mrb_connectingLineColors | reference (array of hex colors)
mrb_connectingLineColor | reference or color
mrb_onlyOnDrag | boolean

Pin Properties

mrb_pinPadding | dimension
mrb_pinRadius | dimension
mrb_pinMinFont | dimension
mrb_pinMaxFont | dimension
mrb_pinColor | reference or color
mrb_pinTextColor | reference or color
mrb_temporaryPins | boolean

Thumb Properties

mrb_minThumbDistance | float or -1 for ignoring
mrb_thumbSize | dimension
mrb_thumbColor | reference or color
mrb_leftThumbColor | reference or color
mrb_rightThumbColor | reference or color
mrb_thumbBoundaryColor | reference or color
mrb_thumbBoundarySize | dimension

Selector Properties (Deprecated & Replaced by Thumb Properties since version 1.4.8)

mrb_selectorColor | reference or color
mrb_leftSelectorColor | reference or color
mrb_rightSelectorColor | reference or color
mrb_selectorSize | dimension
mrb_selectorBoundaryColor | reference or color
mrb_selectorBoundarySize | dimension

ScreenShot

Examples

Layout XML

This is a rangebar with both a lower and upper value

   <com.appyvet.materialrangebar.RangeBar
        android:id="@+id/rangebar1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="40dp"
        android:layout_marginEnd="40dp"
        app:mrb_barWeight="2dp"
        app:mrb_connectingLineColors="@array/connecting_colors"
        app:mrb_connectingLineWeight="4dp"
        app:mrb_leftThumbColor="#FFB300"
        app:mrb_minThumbDistance="-1"
        app:mrb_pinColor="#6c3f6a"
        app:mrb_pinMaxFont="15sp"
        app:mrb_pinMinFont="12sp"
        app:mrb_pinRadius="14dp"
        app:mrb_pinTextColor="@color/white"
        app:mrb_rangeBar="true"
        app:mrb_rangeBarPaddingBottom="30dp"
        app:mrb_rangeBar_rounded="true"
        app:mrb_rightThumbColor="#1E88E5"
        app:mrb_thumbBoundaryColor="@color/accent"
        app:mrb_thumbBoundarySize="2dp"
        app:mrb_thumbSize="10dp"
        app:mrb_temporaryPins="true"
        app:mrb_tickBottomLabels="@array/ticks_labels"
        app:mrb_tickColors="@array/tick_colors"
        app:mrb_tickDefaultColor="@color/indigo500"
        app:mrb_tickDefaultLabel="label"
        app:mrb_tickEnd="10"
        app:mrb_tickHeight="4dp"
        app:mrb_tickInterval="1"
        app:mrb_tickLabelColor="@color/indigo500"
        app:mrb_tickLabelSelectedColor="@color/accent"
        app:mrb_tickLabelSize="4sp"
        app:mrb_tickStart="1"
        app:mrb_tickTopLabels="@array/ticks_labels" />

This is a seekbar with only a single pin (note mrb_rangeBar=false)

   <com.appyvet.materialrangebar.RangeBar
        android:id="@+id/rangebar1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="40dp"
        android:layout_marginEnd="40dp"
        app:mrb_barWeight="2dp"
        app:mrb_connectingLineColors="@array/connecting_colors"
        app:mrb_connectingLineWeight="4dp"
        app:mrb_leftThumbColor="#FFB300"
        app:mrb_minThumbDistance="-1"
        app:mrb_pinColor="#6c3f6a"
        app:mrb_pinMaxFont="15sp"
        app:mrb_pinMinFont="12sp"
        app:mrb_pinRadius="14dp"
        app:mrb_pinTextColor="@color/white"
        app:mrb_rangeBar="false"
        app:mrb_rangeBarPaddingBottom="30dp"
        app:mrb_rangeBar_rounded="true"
        app:mrb_rightThumbColor="#1E88E5"
        app:mrb_thumbBoundaryColor="@color/accent"
        app:mrb_thumbBoundarySize="2dp"
        app:mrb_thumbSize="10dp"
        app:mrb_temporaryPins="true"
        app:mrb_tickBottomLabels="@array/ticks_labels"
        app:mrb_tickColors="@array/tick_colors"
        app:mrb_tickDefaultColor="@color/indigo500"
        app:mrb_tickDefaultLabel="label"
        app:mrb_tickEnd="10"
        app:mrb_tickHeight="4dp"
        app:mrb_tickInterval="1"
        app:mrb_tickLabelColor="@color/indigo500"
        app:mrb_tickLabelSelectedColor="@color/accent"
        app:mrb_tickLabelSize="4sp"
        app:mrb_tickStart="1"
        app:mrb_tickTopLabels="@array/ticks_labels" />

Adding a rangebar listener

  • Add a listener - rangeBar.setOnRangeBarChangeListener which returns left and right index as well as value.
  rangebar.setOnRangeBarChangeListener(new RangeBar.OnRangeBarChangeListener() {
            @Override
            public void onRangeChangeListener(RangeBar rangeBar, int leftPinIndex, int rightPinIndex, String leftPinValue, String rightPinValue) {

            }

            @Override
            public void onTouchEnded(RangeBar rangeBar) {

            }

            @Override
            public void onTouchStarted(RangeBar rangeBar) {

            }
        });

Adding a text formatter

Formats the text inside the pin.

  • Add a formater - IRangeBarFormatter which will return the value of the current text inside of the pin
  • Transform string s into any string you want and return the newly formated string.
rangebar.setFormatter(new IRangeBarFormatter() {
            @Override
            public String format(String s) {
            // Transform the String s here then return s
                return null;
            }
        });

Plan for Future

  • Better documentation.
  • Kotlin conversion

Demo (Outdated)

Get it from the Google Play Store

How to Use

In your project build.gradle. Add the following lines

allprojects {
    repositories {
        jcenter()
    }
}
  • Note: Don't put the above lines inside the buildscript block.

In your app build.gradle. Add the following lines

dependencies {
    implementation 'com.appyvet:materialrangebar:1.4.8'
}

if you are already using android support library inside your project and run into multiple version issues related to android support library then modify the gradle path like this

dependencies {
    compile ('com.appyvet:materialrangebar:1.4.8') {
            exclude module: 'support-compat'
    }
}

Contribution

We don't have enough time to constantly answer the issues and handle updates. So we need all the help we can get. You are always welcome to contribute and help us maintain the library. For Moderator Access create an issue on Github and tag oli107.

License

Copyright 2019  AppyVet, 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

   http://www.apache.org/licenses/LICENSE-2.0

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.

material-range-bar's People

Contributors

2math avatar ahuang13 avatar ajharry69 avatar alqasrawi avatar amoslital avatar ardacebi avatar bryant1410 avatar byteofsilicon avatar cheenu avatar darius-janusauskas avatar dericc avatar idan-an avatar jmiecz avatar johnjohndoe avatar kimor79 avatar krazykira avatar kwiky avatar lam-amsiq avatar lital-nanit avatar lucamtudor avatar mdpearce avatar oknesif avatar oli107 avatar rlshep avatar rubensousa avatar tt1943 avatar ultraon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

material-range-bar's Issues

float number precision loss when the range is large.

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

IllegalArgumentException: Pin value

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?

removing float bubble

how can id disable bubble float of range bar? i just want sometimes to use without float bubble

AppBaseTheme declaration causing issues on pre lollipop devices

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.

Request : foreverPins

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)

Bug in RangeBar.onTouchEvent

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.

Worst lib I ever seen

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!

barColor attribute not working

custom:barColor = "#ffffff"

gives error "No resource identifier found for attribute 'barColor' in package 'com.example.android'

onRestoreInstanceState, Thumbs are not visible

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.

Unable to set Thumb Radius and Thumb Color from XML or Java

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.

Make the size of the bubble text constant?

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.

Event with start and finish of drag

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.

RangeBar Mode => thumbs hiding when u setRangePingByValue , setByIndex, setTick = w/e its always hiding thumbs :D

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

Give user the ability to set Maximium and Minimum Pin font size

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.

Not possible to track when I release my finger from the rangebar?

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!

tickInterval is 100 but rangebar is jumping 600 for first tick.

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>

Rangebar left pin stuck at beginning until dragged 1/3 of the way to the left.

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"/>

Pin text length limitation

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.

Disable moving one pin to position where is second pin

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.

setEnabled(false) makes pins invisible when using permanent pins

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.

It is possible to move thumb out of range

If i drag the thumb fast towards the edge of the screen, it is possible to move the thumb out of the range. I am using pinRadius 0dp and selectorSize 16dp.

Please see attached screenshot. Normally the min value is 0.

screenshot_20151112-123210

Library to inherit from projects color file

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>

Can't set the Maximum Value more than 9999.

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"/>

TickEnd and TickStart does not work

Hey.
I started to use your library, and noticed a strange bug that I found TickEnd and TickStart, but I can still move the pin of range (TickEnd and TickStart)
Here's a screenshot:
Before the move::

After the move:

It is observed on the Android 4.2.2 (API 17) and Android 5.1.1 (API 22)

rangeBar throws NullPointer exception when it crosses an index

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" />

Seekbar mode => thumb not moving when user touching the x axis(value)

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);
    }

Customization issue

  1. is there ability to write on selectors, instead of using pins?
  2. can i apply gradient as line color?

onRestoreInstanceState IllegalArgumentException

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)

Pin disappears on setRangePinsByIndices

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.