Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop Scrollview from moving background image to top while pressing EditText?

I have one background image which have RelativeLayout as it's parent and sibling as ScrollView and ScrollView have one EditText. I am facing problem where background image moving top side when we are clicking Edittext. Please find below code snippet and attached screenshots. How we can restrict scrollview from doing this?

Code:

<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:src="@drawable/dog"
        android:scaleType="centerCrop"/>

<ScrollView
        android:id="@+id/layout_scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:visibility="visible">

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


        <EditText
                android:id="@+id/postal_code"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Postcode"
        />


    </RelativeLayout>
</ScrollView>

Before:

enter image description here

After:

enter image description here

like image 457
Jitesh Mohite Avatar asked Jan 16 '20 16:01

Jitesh Mohite


1 Answers

Add this in Activity Manifest

android:windowSoftInputMode="adjustNothing"
like image 95
Chandan kushwaha Avatar answered Nov 15 '22 10:11

Chandan kushwaha