2

I want to hide listview scrollbar in my xamarin andorid and xamarin ios application's. I have searched many post's but only few post's are having the helpful that to not clear. Please suggest any idea of hide scrollbar in listview.

1

3 Answers 3

4

Here is what I did:

Android custom renderer:

[assembly: ExportRenderer(typeof(CustomListView),typeof(CustomListViewRenderer))]
namespace ImageList.Droid
{
    public class CustomListViewRenderer : ListViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
        {
            base.OnElementChanged(e);

            if(Control != null)
            {
                Control.VerticalScrollBarEnabled = false;
            }
        }
    }
}

iOS custom renderer:

[assembly: ExportRenderer(typeof(CustomListView), typeof(CustomListViewRenderer))]
namespace ImageList.iOS
{
    public class CustomListViewRenderer : ListViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                Control.ShowsVerticalScrollIndicator = false;
            }
        }
    }
}

Remember: We need to use the Custom ListView instead of the native ListView in the PCL Forms

Sign up to request clarification or add additional context in comments.

Comments

4

Update: Now from Xamarin.Forms version 3.5.0, we can use VerticalScrollBarVisibility, HorizontalScrollBarVisibility properties to handle ListView ScrollBarVisibility.

You can also find full source code and document from http://bsubramanyamraju.blogspot.com/2019/03/hide-listview-scrollbar-in-xamarinforms.html

Comments

0

Custom renders for the solution here, check official documents for that https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/listview/

Android:

ListView.VericalScrollbarEnabled = false;

iOS:

UIScrollView.ShowsVerticalScrollIndicator = false;

2 Comments

Hi shiwanka, Thanks for your answer. Can you please write some what detail. I have tried above code in onelementchanged override method but not luck. where we write above code please.
Hi deepak, this is actually custom renders, android and ios having different behaviors.... for achieve that you have to right custom renders in ios and android project level, not in pcl

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.