0

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?

DeepakG
  • 17
  • 6
  • Have you looked at `SetScrollIndicators`? – Cheesebaron Apr 20 '22 at 11:25
  • @Cheesebaron, Yes, I have tried the below code but not worked. `this.VerticalScrollBarEnabled = true; this.SetScrollIndicators(8);` Where 8 indicates the SCROLL_INDICATOR_RIGHT. https://developer.android.com/reference/android/view/View#SCROLL_INDICATOR_RIGHT. Shall you please let me know if I doing it correctly? – DeepakG Apr 20 '22 at 12:06

1 Answers1

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 
ColeX
  • 14,062
  • 5
  • 43
  • 240
  • 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. – DeepakG Apr 21 '22 at 09:27
  • Check my update . – ColeX Apr 27 '22 at 01:47
  • 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. – DeepakG Apr 28 '22 at 18:51