force scrollView to bottom

hello,

I have a scrollview and in side the scrollview linear layout
and I adding dynamically edittext and I want the scroll to be at bottom
but sv.scrollTo(0, sv.bottom) not working

Posts

  • nahumgliknahumglik ILMember

    somebody?

  • CheesebaronCheesebaron DKInsider, University mod

    Try

    ListView.SetSelection(Adapter.Count - 1);
    
  • nahumgliknahumglik ILMember

    I am not using listview, only scrollview and inside linearLayout

  • CheesebaronCheesebaron DKInsider, University mod

    Ah thats right.

    view.ScrollTo(0, view.Bottom);
    

    It should work, however you must do it from the UI thread. So in some cases you need to wrap it in RunOnUiThread()

  • nahumgliknahumglik ILMember

    view.Bottom always return 0 even there is items, and the scroll apear

  • CheesebaronCheesebaron DKInsider, University mod

    Where exactly do you do this? In what part of your code?

  • nahumgliknahumglik ILMember

    in onResume

  • nahumgliknahumglik ILMember

    anybody? I tried every thing and it just not working

  • nahumgliknahumglik ILMember

    ok after a lot of hours searching in google this is what worked fo me

    ``

        private void scrollDownScrollView()
        {
            ScrollView sv = (ScrollView)FindViewById(Resource.Id.scroll);
    
            RunOnUiThread(() =>
            {                
                sv.Post(new Java.Lang.Runnable(aa) );                
            });            
        }
    
        private void aa()
        {
            ScrollView sv = (ScrollView)FindViewById(Resource.Id.scroll);
            sv.FullScroll(FocusSearchDirection.Down);
        }
    

    ``

  • RandomBaresRandomBares USMember

    Thanks for posting your solution, just saved me a lot of googling :)

  • NeseekNeseek INMember

    It worked like charm @nahumglik...
    Thanks a lot...

  • fbs419fbs419 USMember ✭✭
    edited December 2016

    I have this working, i.e.
    protected void ScrollToBottom()
    {
    ScrollView sv = (ScrollView)FindViewById (Resource.Id.scrollView1);
    RunOnUiThread(() =>
    {
    sv.Post(new Java.Lang.Runnable(scrollit));
    });
    }

            private void scrollit()
            {
                ScrollView sv = (ScrollView)FindViewById<ScrollView> (Resource.Id.scrollView1);
                sv.FullScroll(FocusSearchDirection.Down);
            }
    

    But ideally, I would like just to have one method and not hard code the ScrollView resource. How can I pass data to scrollit?

  • Can anyone tell me how to do this with a nested scrollview?
    When i put sv.FullScroll(FocusSearchDirection.Down);
    it says it cannot convert focussearchdirection.Down to int.

    Any help would be greatly appreciated

Sign In or Register to comment.