Search code examples
javaandroidxmllayoutscrollview

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 .

Left one is before showing keyboard and right one is after showing keyboard

im using it beside viewpager :

this is my viewpager xml that contain a lot of edittext .

Fragment 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 .

Main 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>

Solution

  • I used adjustUnspecified in Manifest and its working properly