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?

2
  • Have you looked at SetScrollIndicators? Commented Apr 20, 2022 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. developer.android.com/reference/android/view/…. Shall you please let me know if I doing it correctly? Commented Apr 20, 2022 at 12:06

1 Answer 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 
Sign up to request clarification or add additional context in comments.

3 Comments

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.
Check my update .
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.