Search code examples
androidandroid-fragmentsscrollview

Scroll View is not working when keyboard is open


I am using ScrollView for scrolling my layout.But not working in Fragment class when keyboard is open. I am novice with Fragments.

Here is my XML Code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/settingLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/splash_bg" >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        <ImageView
            android:id="@+id/tree_iv_userSettings"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@drawable/tree_transparent" />
        <ScrollView
            android:id="@+id/sv_rl_user_settings"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:isScrollContainer="true" >

            <RelativeLayout
                android:id="@+id/main_rl_user_settings"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center" >

                <ImageView
                    android:id="@+id/image1"
                    android:layout_width="90dp"
                    android:layout_height="110dp"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="30dp"
                    android:src="@drawable/frame_large" />

                <TextView
                    android:id="@+id/changepassword"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_below="@+id/image1"
                    android:layout_marginLeft="20dp"
                    android:background="@android:color/transparent"
                    android:hint="CHANGE PASSWORD"
                    android:singleLine="true"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColor="@android:color/black"
                    android:textColorHint="@android:color/black" />

                <EditText
                    android:id="@+id/editname"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_below="@+id/changepassword"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="15dp"
                    android:background="@android:color/transparent"
                    android:hint="EDIT NAME"
                    android:maxLength="20"
                    android:singleLine="true"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColorHint="@android:color/black" />

                <EditText
                    android:id="@+id/editphoneno"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_below="@+id/editname"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="15dp"
                    android:background="@android:color/transparent"
                    android:hint="EDIT PHONE NUMBER"
                    android:maxLength="15"
                    android:numeric="integer"
                    android:singleLine="true"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColorHint="@android:color/black" />

                <TextView
                    android:id="@+id/edittype"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_below="@+id/editphoneno"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="15dp"
                    android:background="@android:color/transparent"
                    android:singleLine="true"
                    android:text="EDIT TYPE"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColor="@android:color/black" />

                <TextView
                    android:id="@+id/notification"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_below="@+id/edittype"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="15dp"
                    android:background="@android:color/transparent"
                    android:singleLine="true"
                    android:text="NOTIFICATION"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColor="@android:color/black" />

                <Button
                    android:id="@+id/togNot"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_above="@+id/save"
                    android:layout_alignParentRight="true"
                    android:layout_marginRight="20dp"
                    android:background="@drawable/on_button" />

                <TextView
                    android:id="@+id/save"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/notification"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="30dp"
                    android:background="@android:color/transparent"
                    android:text="SAVE "
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColor="@android:color/black"
                    android:textSize="40dp" />

                <ProgressBar
                    android:id="@+id/progressBar1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignBottom="@+id/image1"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="27dp" />
            </RelativeLayout>
        </ScrollView>

        <RelativeLayout
            android:id="@+id/bottomRelay"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_margin="7.5dp"
            android:background="@android:color/transparent"
            android:visibility="gone" >

            <TextView
                android:id="@+id/Upload"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:background="#ededed"
                android:gravity="center"
                android:text="Upload Photo"
                android:textColor="#8F8F8F"
                android:textSize="20dp"
                android:textStyle="bold" />

            <ImageView
                android:id="@+id/border1"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_below="@id/Upload"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:background="#939393" />

            <TextView
                android:id="@+id/choose_existing"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_below="@+id/border1"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:layout_marginTop="1dp"
                android:background="#ededed"
                android:gravity="center"
                android:text="Library"
                android:textColor="#007AFF"
                android:textSize="20dp"
                android:textStyle="bold" />

            <ImageView
                android:id="@+id/border2"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_below="@id/choose_existing"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:background="#939393" />

            <TextView
                android:id="@+id/Camera"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_below="@+id/border2"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:layout_marginTop="1dp"
                android:background="#ededed"
                android:gravity="center"
                android:text="Camera"
                android:textColor="#007AFF"
                android:textSize="20dp"
                android:textStyle="bold" />

            <ImageView
                android:id="@+id/border3"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_below="@id/Camera"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:background="#939393" />

            <TextView
                android:id="@+id/cancel"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_below="@+id/border3"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:layout_marginTop="20dp"
                android:background="#ededed"
                android:gravity="center"
                android:text="Cancel"
                android:textColor="#007AFF"
                android:textSize="20dp"
                android:textStyle="bold" />
        </RelativeLayout>

        <ImageView
            android:id="@+id/dropimg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/drop_down"
            android:visibility="invisible" />
    </RelativeLayout>

</RelativeLayout>

Manifest code of that Activity:

android:name="com.treeapp.header.Header"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
android:theme="@android:style/Theme.NoTitleBar"

Solution

  • use this in ur manifest

    android:windowSoftInputMode="adjustPan|stateAlwaysVisible"