I am trying to implement Vertical slider in Xamarin.forms. I know for that I need to create render classes in ios and android respectively. For ios, my renderer seems to be working fine. For android I am following the link https://forums.xamarin.com/discussion/69933/vertical-slider. However the solution provided in above link left me with a slider with no thumb. Is there any way to implement vertical slider for android in Xamarin.forms?
相关问题
- Custom controls disabled. There was an internal is
- Xamarin. The name 'authorEntry does not exist
- How to implement only emoji keyboard for Entry?
- Error:Xamarin.Forms targets have been imported mul
- Store data and global variables using the Applicat
相关文章
- Xamarin form MessagingCenter Unsubscribe is not wo
- Reload data on tab selected in a fragment using vi
- The type initializer for 'SQLite.SQLiteConnect
- What to use for AttributeName in Xamarin Mac
- How to use native C++ libraries in Mono for Androi
- Start an Activity from another Activity on Xamarin
- Xamarin build error: defining a default interface
- Xamarin Android Player Error when attempting to fi
I do this way. I think is intuitive and I don't have to worry about coordinates. X and Y are still relative to the wanted actual Left and Top of the Slider. Note the Rectangle bounds in SetLayoutBounds has Height and Width swapped on purpose.
I had the same issue, and spent some time searching. My solution, as other commenters, was to rotate the slider. As it turns out that is quite the finicky thing to do in Forms. The rotation is around the center point and is applied after any positioning, which is why things tend to end up off target (or off screen..). I ended up using a RelativeLayout to apply the correct size and position and wrapped it up in a ContentView to make it nice and easy to use.
Use like this:
The VerticalContentView can be used like any other ContentView. Any view added to it will be rotated by -90 degrees. The rotation can be customized by using the ContentRotation property.
Note that any view can be rotated, not just a slider.
This is the class.
It's in C# as I found no way of doing arithmetic based on parent dimensions in XAML.
I'm pretty new to Xamarin (and XAML in general), so there might be negative effects of doing it this way that I am not aware of. Any criticisms are welcome.
This works, sort of. It still has a lot of irritating weirdness to it, but, does the core job of: Has vertical sliders, align next to each other.
Some things I've gleaned from experimentation:
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/slider https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/absolute-layout
You can also check this blog for complete source code of vertical sliders in xamarin forms in android and iOS
https://xamarinexperience.blogspot.com/search?q=Vertical+slider