Editor inside Scrollview not scrolling.

I have an editor control inside a StackLayout which is inside a ScrollView. I can scroll all the controls but when I go into an editor control if the text superpasses the editor's height I cannot scroll into the previously added text. So if the line goes out of the visible part of the editor I cannot go back to it, the only way is to erase the whole text and write something up again. So basically trying to scroll inside the editor results in scrolling out the controls inside the scrollview but I just want to scroll inside the editor. By the way editors are added to the stacklayout dynamically.

                <StackLayout x:Name="content" Orientation="Vertical"></StackLayout>

Any suggestions?

Thank you.


  • MarcoMacedoMarcoMacedo BRMember

    DId you found any solution?

  • KaranPatelKaranPatel USMember

    Hi found any solution to this problem

  • KaranPatelKaranPatel USMember

    Hi found any solution to this problem

  • DurgaPrasadMailapalliDurgaPrasadMailapalli BYUniversity ✭✭
    edited January 27

    I found solution for this problem, it is working for me.

    1. Write a listener
      public class DroidTouchListener : Java.Lang.Object, View.IOnTouchListener
      public bool OnTouch(View v, MotionEvent e)
      if ((e.Action & MotionEventActions.Up) != 0 && (e.ActionMasked & MotionEventActions.Up) != 0)
      return false;

    2. Write custom renderer
      public class CustomEditorRenderer : EditorRenderer
      protected override void OnElementChanged(ElementChangedEventArgs e)
      if (e.OldElement == null)
      var nativeEditText = (global::Android.Widget.EditText)Control;

                  //While scrolling inside Editor stop scrolling parent view.
                  nativeEditText.OverScrollMode = OverScrollMode.Always;
                  nativeEditText.ScrollBarStyle = ScrollbarStyles.InsideInset;
                  nativeEditText.SetOnTouchListener(new DroidTouchListener());
                  //For Scrolling in Editor innner area
                  Control.VerticalScrollBarEnabled = true;
                  Control.MovementMethod = ScrollingMovementMethod.Instance;
                  Control.ScrollBarStyle = Android.Views.ScrollbarStyles.InsideInset;
                  //Force scrollbars to be displayed
                  Android.Content.Res.TypedArray a = Control.Context.Theme.ObtainStyledAttributes(new int[0]);
  • RobinHosRobinHos NLMember

    Thanks @DurgaPrasadMailapalli this worked for me.

  • Oliv3rOliv3r USMember ✭✭

    @DurgaPrasadMailapalli @RobinHos Where do you put the droidListener? And do you have a similar solution to iOS?

  • DurgaPrasadMailapalliDurgaPrasadMailapalli BYUniversity ✭✭

    1. Where do you put the droidListener?
    You can put anywhere in the hierarchy of android solution, and call from custom renderer by this following code nativeEditText.SetOnTouchListener(new DroidTouchListener());

    1. do you have a similar solution to iOS?
      not required for iOS it will scroll individually.
  • dpedrinhadpedrinha DEMember ✭✭✭

    @DurgaPrasadMailapalli that worked great! Thsnk you.

    So sad that Xamarin forms miss such basic behaviors.

Sign In or Register to comment.