调整平移不适用于滚动视图之外的参数

adjust pan is not working for parameters that are out side of scrollview

我在我的清单中使用调整平移 activity 并且它在滚动视图中正常工作,但我有一些超出滚动视图的东西正在调整大小。

我将此代码放在清单的 activity 上:

android:windowSoftInputMode="adjustPan"

你可以在图片中看到。

我在 viewpager 旁边使用它:

这是我的 viewpager xml,其中包含很多 edittext。

片段Xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <AutoCompleteTextView android:id="@+id/autotext"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:nextFocusUp="@id/autotext"
        android:nextFocusLeft="@id/autotext"/>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:orientation="horizontal"
                android:weightSum="2">

                <Spinner
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:id="@+id/spinnerKind"
                    android:layout_weight="1"/>


                <Spinner
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:id="@+id/spinnerSazande"
                    android:layout_weight="1"/>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:orientation="horizontal"
                android:weightSum="2"
                >

                <EditText
                    android:id="@+id/model"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="مدل"
                    android:focusableInTouchMode="true"/>

                <EditText
                    android:id="@+id/serial"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="سریال"
                    android:focusableInTouchMode="true"
                    />


            </LinearLayout>

            <LinearLayout
                android:id="@+id/LIMEI"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:orientation="horizontal"
                android:weightSum="2"
                >

                <EditText
                    android:id="@+id/IMEI1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="IMEI"
                    android:gravity="right"
                    android:focusableInTouchMode="true"/>

                <EditText
                    android:id="@+id/IMEI2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="IMEI2"
                    android:gravity="right"
                    android:focusableInTouchMode="true"/>





            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:orientation="horizontal"
                android:weightSum="2"
                >

                <EditText
                    android:id="@+id/Size"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="سایز"
                    android:focusableInTouchMode="true"/>

                <EditText
                    android:id="@+id/Color"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="رنگ"
                    android:focusableInTouchMode="true"/>





            </LinearLayout>

            <LinearLayout
                android:id="@+id/LMojdegani"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:orientation="horizontal"
                android:weightSum="2"
                >

                <EditText
                    android:id="@+id/MacAddress"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="MacAddress"
                    android:gravity="right"
                    android:focusableInTouchMode="true"/>


                <EditText
                    android:id="@+id/mojdegani"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="مژدگانی"
                    android:focusableInTouchMode="true"/>


            </LinearLayout>


            <LinearLayout
                android:id="@+id/LFactor"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:orientation="horizontal"
                android:weightSum="2"
                >

                <EditText
                    android:id="@+id/FactorNumber"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="شماره فاکتور"
                    android:focusableInTouchMode="true"/>


                <EditText
                    android:id="@+id/NameForoshande"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="نام فروشنده"
                    android:focusableInTouchMode="true"/>


            </LinearLayout>

            <LinearLayout
                android:id="@+id/LTarikh"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:orientation="horizontal"
                android:weightSum="1"
                >

                <EditText
                    android:id="@+id/Tarikh_Kharid"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="تاریخ خرید"
                    android:focusableInTouchMode="true"/>



            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:orientation="horizontal"
                android:weightSum="2"
                >

                <EditText
                    android:id="@+id/Name"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="نام"
                    android:focusableInTouchMode="true"/>


                <EditText
                    android:id="@+id/LastName"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="نام خانوادگی"
                    android:focusableInTouchMode="true"/>


            </LinearLayout>


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:orientation="horizontal"
                android:weightSum="2"
                >

                <EditText
                    android:id="@+id/CodeMelli"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="کد ملی 10 رقمی"
                    android:focusableInTouchMode="true"/>


                <EditText
                    android:id="@+id/Mobile"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="شماره موبایل"
                    android:focusableInTouchMode="true"/>


            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:orientation="horizontal"
                android:weightSum="2"
                >

                <EditText
                    android:id="@+id/Explain"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:hint="توضیحات مربوط به کالا (اختیاری)"
                    android:focusableInTouchMode="true"/>


            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="80dp"
                android:orientation="vertical"
                android:weightSum="2"
                >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="جنسیت"
                    android:gravity="center_vertical"
                    android:layout_marginRight="5dp"
                    android:layout_weight="1"/>

               <RadioGroup
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:orientation="horizontal"
                   android:layout_weight="1"
                   android:weightSum="2">

                   <RadioButton
                       android:id="@+id/mard"
                       android:layout_width="match_parent"
                       android:layout_height="match_parent"
                       android:layout_weight="1"
                       android:text="مرد"/>

                   <RadioButton
                       android:id="@+id/zan"
                       android:layout_width="match_parent"
                       android:layout_height="match_parent"
                       android:layout_weight="1"
                       android:text="زن"/>


               </RadioGroup>


            </LinearLayout>


            <Space
                android:layout_width="wrap_content"
                android:layout_height="20dp"
                android:layout_weight="1" />


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:orientation="horizontal"
                android:weightSum="1"
                >

               <TextView
                   android:id="@+id/confirm"
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:text="تایید"
                   android:gravity="center"
                   android:background="@drawable/confirm"
                   android:layout_weight="1"
                   android:clickable="true"
                   android:layout_margin="5dp"/>


            </LinearLayout>


        </LinearLayout>
    </ScrollView>
</LinearLayout>

这是我的主要 xml,它有一个带有 4 个文本的线性布局,可以点击这些文本并通过选择这些文本查看页面之间的寻呼机切换。

主要 XML :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="2"
        android:orientation="vertical">


            <android.support.v7.widget.CardView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1.85">

                <LinearLayout
                    android:layout_margin="5dp"
                    android:background="@drawable/card2"
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:weightSum="4"
                    android:layout_weight="1.8">


                    <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        >

                        <TextView
                            android:gravity="center"
                            android:text="کالای مسروقه"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:id="@+id/stolled"
                            android:layout_weight="1"
                            android:clickable="true"/>
                    </LinearLayout>

                    <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        >

                        <TextView
                            android:gravity="center"
                            android:text="کالای گم شده"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:id="@+id/losted"
                            android:layout_weight="1"
                            android:clickable="true"
                            />
                    </LinearLayout>

                    <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        >

                        <TextView
                            android:gravity="center"
                            android:text="پیدا شده"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:id="@+id/founded"
                            android:layout_weight="1"
                            android:clickable="true"/>
                    </LinearLayout>

                    <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        >

                        <TextView
                            android:gravity="center"
                            android:text="کالای نو"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:id="@+id/fresh"
                            android:layout_weight="1"
                            android:clickable="true"/>
                    </LinearLayout>

                </LinearLayout>
            </android.support.v7.widget.CardView>




        <android.support.v4.view.ViewPager
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.15"
            android:id="@+id/ViewPager"
            >


        </android.support.v4.view.ViewPager>

    </LinearLayout>

</LinearLayout>

我认为,正如你所说的那样,你已经在你的 manifest 中声明了 adjustResize,如下图所示?

 <activity
            android:name=".MainActivity"
            android:windowSoftInputMode="adjustResize"
            android:screenOrientation="landscape"/>

那么,请尝试添加

android:fitsSystemWindows="true"

在您的xml的父布局中。

将此行添加到您的 ScrollView android:fillViewport="true"

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

(或)

OncreateView() this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);)

里面添加这一行
 serial.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            serial.requestLayout();
            getActivity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);

            return false;
        }
    });

我在 Manifest 中使用了 adjustUnspecified 并且它工作正常