0

I had designed a screen with logo image view and title on the top which takes about 80 dp height. Then a frame layout is kept vertically next to it. The frame layout loads fragment dynamically. The fragment holds a scrollview with input fields. The problem comes here, when the focus goes to edit text, the whole screen scrolls up. I want only the scrollview in the fragment to scroll. The top area has to be fixed. Please go through the layout design provided for Holder Activity and its fragment. I want only the scrollview to shrink above the keyboard. Can anyone help me as I am very new to android development.

HolderActivity Layout

<?xml version="1.0" encoding="utf-8"?>

<ImageView
    android:id="@+id/patternImageView"
    style="@style/WFImageViewPatternBG"/>

<ImageView
    android:id="@+id/titleImageView"
    style="@style/WFImageViewTitle"
    android:layout_centerHorizontal="true"/>

<TextView
    android:id="@+id/fertilityTextView"
    style="@style/WFTextStyleFertilityTitle"
    android:layout_below="@id/titleImageView"
    />

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragmentPlaceholder"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/fertilityTextView"
    android:layout_marginTop="20dp">

    <!-- Fragment will go here eventually, but it's not added in the layout -->

</FrameLayout>

Fragment Activity Layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ideasurge.winfertility.CreateAccountInputFragment">

<ScrollView
    android:id="@+id/inputScrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/createAcctNextBtn">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/createAcctTitleTextView"
            style="@style/WFTextStyleBoldPinkTitle"
            android:text="Create An Account" />

        <EditText
            android:id="@+id/first_name_edit_txt"
            style="@style/WFEditTextStyle"
            android:hint="First Name"
            android:background="@drawable/rounded_border_pink"
            android:layout_marginTop="20dp"
            android:layout_below="@+id/createAcctTitleTextView" />

        <EditText
            android:id="@+id/last_name_edit_txt"
            style="@style/WFEditTextStyle"
            android:hint="Last Name"
            android:background="@drawable/rounded_border_pink"
            android:layout_below="@+id/first_name_edit_txt" />

        <EditText
            android:id="@+id/email_pwd_edit_txt"
            style="@style/WFEditTextStyle"
            android:hint="Email Address"
            android:background="@drawable/rounded_border_pink"
            android:layout_below="@+id/last_name_edit_txt" />

        <EditText
            android:id="@+id/phone_no_edit_txt"
            style="@style/WFEditTextStyle"
            android:hint="Phone Number"
            android:background="@drawable/rounded_border_pink"
            android:layout_below="@+id/email_pwd_edit_txt" />

        <EditText
            android:id="@+id/create_pwd_edit_txt"
            style="@style/WFEditTextStyle"
            android:hint="Create Password"
            android:background="@drawable/rounded_border_pink"
            android:layout_below="@+id/phone_no_edit_txt" />

        <EditText
            android:id="@+id/dob_edit_txt"
            style="@style/WFEditTextStyle"
            android:hint="Date of Birth"
            android:background="@drawable/rounded_border_pink"
            android:layout_below="@+id/create_pwd_edit_txt" />

        <EditText
            android:id="@+id/gender_edit_txt"
            style="@style/WFEditTextStyle"
            android:hint="Gender"
            android:background="@drawable/rounded_border_pink"
            android:layout_below="@+id/dob_edit_txt" />

        <TextView
            android:id="@+id/companySectionTitle"
            style="@style/WFTextStyleSectionPinkTitle"
            android:text="Your company may provide Fertility Benefits."
            android:layout_marginLeft="40dp"
            android:layout_marginRight="40dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="20dp"
            android:layout_below="@+id/gender_edit_txt"/>

        <EditText
            android:id="@+id/company_edit_txt"
            style="@style/WFEditTextStyle"
            android:hint="Name of Company"
            android:background="@drawable/rounded_border_pink"
            android:layout_below="@+id/companySectionTitle" />

        <EditText
            android:id="@+id/insurance_id_edit_txt"
            style="@style/WFEditTextStyle"
            android:hint="Insurance Subscriber ID"
            android:background="@drawable/rounded_border_pink"
            android:layout_below="@+id/company_edit_txt" />

    </RelativeLayout>

</ScrollView>

<Button
    android:id="@+id/createAcctNextBtn"
    style="@style/WFButtonStylePink"
    android:text="NEXT"
    android:layout_marginTop="20dp"
    android:layout_marginBottom="20dp"
    android:layout_alignParentBottom="true"
    />

Punit Sharma
  • 2,951
  • 1
  • 20
  • 35
sree_iphonedev
  • 3,514
  • 6
  • 31
  • 50

1 Answers1

0

This may be helpful:

android:windowSoftInputMode="adjustPan"

Use it in the manifest activity tag like this:

<activity  
    android:name=".Activity"
    android:windowSoftInputMode="adjustPan" />

Here you can use other option instead of adjustpan.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
jigar savaliya
  • 474
  • 1
  • 8
  • 21