question

njsokalski avatar image
0 Votes"
njsokalski asked LeonLu-MSFT edited

Slider or RangeSlider for AndroidX

I am working on adding a slider to my app. I have found com.google.android.material.slider.RangeSlider & com.google.android.material.slider.Slider, but I would prefer (if one exists) to use a slider from AndroidX. Does AndroidX include any kind of slider control? Thanks.

dotnet-android
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LeonLu-MSFT avatar image
0 Votes"
LeonLu-MSFT answered LeonLu-MSFT edited

Hello,​

Welcome to our Microsoft Q&A platform!

Does AndroidX include any kind of slider control?

You can use androidx.appcompat.widget.AppCompatSeekBar in the xamarin.android.

<androidx.appcompat.widget.AppCompatSeekBar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:max="100"
    />


Best Regards,

Leon Lu



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 10
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@njsokalski Is that your needs?

0 Votes 0 ·

I'm trying to use com.google.android.material.slider.Slider but it gives me the following error in the designer:

131098-screenshot-2021-09-10-123625.png

In my styles.xml file I have the following:

 <style name="AppTheme" parent="Theme.Design.NoActionBar">
 </style>

I also tried changing that to:

 <style name="AppTheme" parent="Theme.MaterialComponents.NoActionBar">
     <item name="colorOnBackground">@color/Transparent</item>
 </style>

But it still didn't work. What do I need to do?



0 Votes 0 ·

II use this nuget libary.

131460-image.png

Then I add this control in the layout.

<com.google.android.material.slider.Slider
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>/>

i get the following error, But when I run it, Slider could running normally.

131519-image.png

131553-image.png


0 Votes 0 ·
image.png (8.0 KiB)
image.png (24.3 KiB)

I do have that NuGet package included. When I try to run the app, I get the following error on SetContent(...) in my OnCreate event handler:

Android.Views.InflateException
Message=Binary XML file line #2 in com.companyname.kakuro:layout/activity_main: Binary XML file line #2 in com.companyname.kakuro:layout/activity_main: Error inflating class com.google.android.material.slider.Slider

Is there anything else I need to do?

0 Votes 0 ·
Show more comments