'How to set the attribute "android:scrollbars" programmatically for a view in Xamarin Android C#?
I am using NestedScrollView control in my Xamarin Android application as recommended in Android forums. In which the scrollbars are not visible, but the scrolling is working. I want to enable to enable the scrollbars and tried the scrollbar related APIs in the NestedScrollView and found it was not working. While searching I found this link, where it says to set the "android:scrollbars" attribute in XML file to enable it. I would like to set this programmatically in C# but I am unable to find any relevant code for this. Anyone please advice me how to achieve this?
Solution 1:[1]
This is a known issue which I reported here : https://github.com/xamarin/Xamarin.Forms/issues/7629.
This issue has not been fixed yet .
The only workaround is to enable the scrollbar in xml(based on my test).
Xml
<androidx.core.widget.NestedScrollView
android:id="@+id/nsvMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
>
Code behind
var view = FindViewById<NestedScrollView>(Resource.Id.nsvMain);
view.VerticalScrollBarEnabled = true; //not work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
