androidkotlinmaterial-components-androidrangesliderandroid-slider

How to change material slider font


How to change material slider bubble typeface programmatically?

enter image description here


Solution

  • Currently (1.3.0) the only way to define the textAppearance and the font used by the Tooltip in the Slider is with a style:

    <style name="App.Slider" parent="@style/Widget.MaterialComponents.Slider">
        <item name="labelStyle">@style/App.Tooltip</item>
    </style>
    
    <style name="App.Tooltip" parent="Widget.MaterialComponents.Tooltip">
        <item name="android:textAppearance">@style/TextAppearance.MaterialComponents.Tooltip</item>
    </style>
    

    If you would like to use a reflection (I discourage it) you have to access to List<TooltipDrawable> labels defined in the BaseSlider class.
    Then you can use the methods setTextAppearance or setTextAppearanceResource defined in the TooltipDrawable class