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?
1 Answer
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
3 Comments
DeepakG
Shall you please let me know on the workaround by sharing the code you have used in XML and how you mapped to ScrollView which is created from the code? Thanks.
ColeX
Check my update .
DeepakG
Thanks for the update. However it requires to be done programmatically for my case. I will be waiting for the fix or any other workarounds.
SetScrollIndicators?this.VerticalScrollBarEnabled = true; this.SetScrollIndicators(8);Where 8 indicates the SCROLL_INDICATOR_RIGHT. developer.android.com/reference/android/view/…. Shall you please let me know if I doing it correctly?