Scrollview 不在文本框焦点上滚动(Android)

Scrollview Not Scrolling on Textbox Focus(Android)

我在 Android 应用程序中遇到滚动视图问题。当我聚焦文本框时,它不会滚动到文本框。它正在跳到视图的顶部。

对不起我的英语,我希望你能理解我的问题。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/svPages"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusableInTouchMode="true"
    android:fillViewport="true"
    android:isScrollContainer="true"
    >
    <LinearLayout
        android:id="@+id/LLContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:focusable="false" />
</ScrollView>

和activity

 protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            LinearLayout linearLayout = FindViewById<LinearLayout>(Resource.Id.LLContainer);

            RelativeLayout layoutPage = new RelativeLayout(this);
            layoutPage.Focusable = false;

            for (int j = 1000; j < 4000; j = j + 1000)
            {
                EditText editText = new EditText(this);
                editText.SetWidth(150);
                editText.SetHeight(50);
                editText.SetX(30);
                editText.SetY(j+1000);

                layoutPage.AddView(editText);

            }

            int heightInDP = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 2250, Resources.DisplayMetrics);
            LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            layoutPage.SetMinimumHeight(heightInDP);
            linearLayout.AddView(layoutPage, linearLayoutParams);

        }

问题是 setx 和 sety。在我删除它之后,它可以正常工作。 因此,作为解决方法,我将布局更改为框架布局并使用了 SetTop 和 SetLeft 这对我有用。