Search code examples
androidsliderrangeslider

Material slider wrong drag label show


If I use material slider example from here range slider when drag looks like this: enter image description here But when I use it i my application, when I drag slider I see only one slider label: enter image description here

How can I fix it? My code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="true"

    android:focusable="true"

    android:focusableInTouchMode="true"
    android:orientation="vertical"
    android:paddingStart="15dp"
    android:paddingEnd="15dp"
    tools:context=".presentation.sub_search.view.SubSearchFragment">


    <com.google.android.material.slider.Slider
        android:id="@+id/prices_slider"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"

        android:layout_marginTop="40dp"
        android:stepSize=".1"
        android:valueFrom="0"

        android:valueTo="100" />
</LinearLayout>

Slider pricesSlider = view.findViewById(R.id.prices_slider);
pricesSlider.setValues(10f, 70f);

UPD:

I have this problem only inside fragments. If I use the same code in activity, I have no problems


Solution

  • The problem was in fragment container. After I change container to CoordinatorLayout problem fixed. In other place problem fixed after I replace ViewPager with ViewPager2