maui
maui copied to clipboard
ScrollBarVisibility "Always" is not consistent.
Description
I have my vertical scrollbar set to "Always". When the page is loaded, the scrollbar is there. Only AFTER I scroll in the scrollview, the scrollbar is visible, but then disappears when idle.
Steps to Reproduce
<ScrollView HeightRequest="130"
VerticalScrollBarVisibility="Always">
<Label Text="{Binding Description}"
Margin="0,0,0,16"/>
</ScrollView>
Link to public reproduction project repository
N/A
Version with bug
6.0.312
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 12
Did you find any workaround?
No response
Relevant log output
No response
On Android that appears to be behaving "correctly" as it maps to VerticalScrollBarEnabled.
To make the scrollbars truly visible all the time requires ScrollBarFadingEnabled to be false in the Android code. Changing the behavior of ScrollBarVisibility.Always would probably be considered a breaking change (despite its confusing name).
@GalaxiaGuy you did some digging on this? Could you maybe add some links to the code for this?
My initial reaction was: hm, yeah that's how some platforms work. Like on iOS I don't think you can even get the scrollbars to stay visible or it's highly discouraged by Apple at least. But on Android it seems like we could, but maybe we're mapping it to the wrong property?
Or, the bug might be here that the naming is not really clear about what it actually does. As it seems for Android where we map it to it seems to be something that enables and disables scrolling regardless of content is overflowing or not rather than showing or hiding the actual scrollbars.
It might be a breaking change, but that doesn't mean that we need to keep a potential bug alive because of that 😄
Hi @PrestigiousF. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
I'm not sure what is being requested by the bot... Just giving and update - I'm not sure how to implement the suggestion by @GalaxiaGuy , as it's not a option in Xaml, I'm fairly new to MAUI.
@jfversluis My research was mainly this stackoverflow post:
https://stackoverflow.com/questions/5702502/how-to-always-show-scrollbar
It boils down to disabling the fade using setScrollbarFadingEnabled(false) or setScrollBarFadeDuration(0) (while also doing the existing thing of enabling them even if the content doesn't scroll).
@PrestigiousF This functionality is only available in the native Android code, and some work would be need to expose it. There is a pretty in depth guide here:
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/handlers/customize?view=net-maui-7.0
Although based on the comments by @jfversluis the current behavior of Always may be changed to anyway.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Can repro on android platform with sample code.
https://developer.android.com/reference/android/view/View#setScrollbarFadingEnabled(boolean) is inherited by ScrollViw on Android. Setting it has worked for renderers for me on Xamarin.Forms (and now on MAUI).
Curiously, it doesn't seem to work when appending to a handler mapping, e.g.
Microsoft.Maui.Handlers.ScrollViewHandler.Mapper.AppendToMapping("ObviousScrollViewCustomization",
(handler, view) => {
handler.PlatformView.ScrollbarFadingEnabled = false;
});
I'll keep poking at it.
Curiously, it doesn't seem to work when appending to a handler mapping, e.g.
Microsoft.Maui.Handlers.ScrollViewHandler.Mapper.AppendToMapping("ObviousScrollViewCustomization", (handler, view) => { handler.PlatformView.ScrollbarFadingEnabled = false; });I'll keep poking at it.
Add "handler.PlatformView.ScrollBarFadeDuration = 0;" might be useful.
This default behavior is kinda annoying :/
Confirmed it's working with this handler mapping :
ScrollViewHandler.Mapper.AppendToMapping("ScrollViewFixScrollBar", static (handler, view) =>
{
handler.PlatformView.ScrollbarFadingEnabled = false;
handler.PlatformView.ScrollBarFadeDuration = 0;
});