Forum Xamarin.Android

Screen rotation and scrollability challange

Hi Everyone

I have a problem with my controls not giving complete scroll-ability after and orientation change. I have an activity with a top listview and at the bottom a grid. (buttons in the middle). Everything is fine until I change orientation and then my controls don't scroll completely. See code below:

Thanks for your help

    public override void OnConfigurationChanged(Android.Content.Res.Configuration newConfig)
    {
        base.OnConfigurationChanged(newConfig);
        HorizontalScrollView llTop = FindViewById<HorizontalScrollView>(Resource.Id.horizontalView1);
        LinearLayout llButtons = FindViewById<LinearLayout>(Resource.Id.llButtons);
        ScrollView svu = FindViewById<ScrollView>(Resource.Id.scrollView1);

        if (newConfig.Orientation == Android.Content.Res.Orientation.Portrait)
        {
            llTop.LayoutParameters.Height = Convert.ToInt32(Resources.DisplayMetrics.HeightPixels * .47);
            llButtons.LayoutParameters.Height = Convert.ToInt32(Resources.DisplayMetrics.HeightPixels * .06);
            svu.LayoutParameters.Height = Convert.ToInt32(Resources.DisplayMetrics.HeightPixels * .57);
        }
        else if (newConfig.Orientation == Android.Content.Res.Orientation.Landscape)
        {
            llTop.LayoutParameters.Height = Convert.ToInt32(Resources.DisplayMetrics.HeightPixels * .40);
            llButtons.LayoutParameters.Height = Convert.ToInt32(Resources.DisplayMetrics.HeightPixels * .08);
            svu.LayoutParameters.Height = Convert.ToInt32(Resources.DisplayMetrics.HeightPixels * .62);
        }
    }

<?xml version="1.0" encoding="utf-8"?>










































Sign In or Register to comment.