How to make a view not to scroll with soft input keyboard?

279 views Asked by At

I have 2 layouts

  1. Options layout: should scroll up with keyboard

  2. Layout(linear2) shouldn’t scroll up with keyboard. (Keyboard should hide the particular layout , while scrolling it should be reachable)

'Options' layout working as expected. But the problem is with the layout(linear2) which also scrolls up with keyboard. How to fix it?

Attached the xml file below:

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ScrollView
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/options"
        android:clipChildren="true"
        android:fillViewport="true" 
        >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#ffffff" >

            <LinearLayout
                android:id="@+id/linear1
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                  android:orientation="vertical"
                >

                <EditText
                    android:id="@+id/edittext1
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                  />
            <EditText
                    android:id="@+id/edittext2
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                  />

            </LinearLayout>
<!-- shouldnot scroll up with keyboard -->
            <LinearLayout
                android:id="@+id/linear2
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:orientation="vertical" 
                >
                <TextView
                    android:id="@+id/txtview1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_above="@+id/linear3"
                    android:paddingBottom="10dp"
                    android:visibility="gone" />

                <LinearLayout
                    android:id="@+id/linear3"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="gone" />
            </LinearLayout>
        </RelativeLayout>
    </ScrollView>

<!-- scrolls up with soft input keyboard -->
    <RelativeLayout
        android:id="@+id/options"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="#f8f8f8"
         >

        <Button
            android:id="@+id/save"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            />

        <Button
            android:id="@+id/cancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
           android:layout_alignParentRight="true"
            />


    </RelativeLayout>
</RelativeLayout>
0

There are 0 answers