简体   繁体   English

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

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

Im using adjust pan in my manifest activity and its working properly for scroll view but i have something out of scroll view that is resizing . 我在清单活动中使用了调整平移,它在滚动视图中正常工作,但是在滚动视图中我正在调整某些内容。

i put this code on activity on manifest : 我将此代码放在清单上的活动中:

android:windowSoftInputMode="adjustPan"

you can see that in the picture . 您可以在图片中看到它。

左一个在显示键盘之前,右一个在显示键盘之后

im using it beside viewpager : 我在viewpager旁边使用它:

this is my viewpager xml that contain a lot of edittext . 这是我的viewpager xml,其中包含很多edittext。

Fragment Xml : 片段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>

and this is my main xml that have a linearlayout with 4 text that is clickable and by selecting on those texts view pager change between pages . 这是我的主要xml文件,具有线性布局,带有可单击的4个文本,通过在这些文本上选择查看页面之间的寻呼机更改。

Main XML : 主要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>

I think, as per you said in question,you have declared adjustResize in your manifest like below right? 我认为,按照您所说的,您已在清单中声明了AdjustResize ,如右下方所示?

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

Then, please try to adding 然后,请尝试添加

android:fitsSystemWindows="true"

in parent layout of your xml. 在xml的父级布局中。

Add this line inyour ScrollView android:fillViewport="true" ScrollView android:fillViewport="true"添加此行

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

(or) (要么)

Add this line inside OncreateView() this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);) 将此行添加到OncreateView()this.getWindow( 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;
        }
    });

我在清单中使用了adjustUnspecified ,它可以正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM