2

I know that in Android, when the soft keyboard is visible, and the application is not in full screen mode, Android repositions and pushes the layout above, so that a text box is not hidden behind the keyboard. For this we add the following to our manifest

    android:windowSoftInputMode="adjustResize|stateHidden"

Also the view needs to be scrollable. My layout is listed below. All this works fine, the text box moves up, but my need is to move it up all the way to the top of the screen or at least well above the keyboard. I have an autocompletetextview which shows a list of suggestions when I type, however since the keyboard takes half the screen and the text box moves just above the keyboard, the list of suggestions hovers above the text box as I type, I need the text box to move well above, near the top of the screen so that the list of suggestions shows under the autocompletetextview instead of above it. Can it be done? (Via code or some configuration?)

    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:layout_below="@+id/navbar"
    android:layout_above="@+id/navbar2">

    <ScrollView
        android:id="@+id/masterContainerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="#E9E9E9"
        android:isScrollContainer="true"
        android:scrollbars="none" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_margin="30dp"
            android:gravity="center"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/apptitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:layout_weight="0.11"
                android:fontFamily="Roboto"
                android:text="Please Enter The Details Below"
                android:textColor="#444444"
                android:textSize="20sp" />

            <Spinner
                android:id="@+id/spinner"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="30dp"
                android:prompt="@string/plspinner" />

            <AutoCompleteTextView
                android:id="@+id/autosuggestProducts"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="30dp"
                android:ems="10"
                android:textColor="#444444" >
            </AutoCompleteTextView>

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="30dp"
                android:gravity="center"
                android:onClick="goToResults"
                android:text="@string/search" />
        </LinearLayout>
    </ScrollView>
</LinearLayout>
4
  • Try using only android:windowSoftInputMode="adjustResize". You have left the margin for layout. Maybe because of that textview is not moving to the top.
    – Aniruddha
    Jun 16, 2014 at 9:57
  • I already have the above config in my manifest. Can you explain what you meant by I have left margin for layout? Jun 16, 2014 at 10:08
  • try removing android:layout_margin="30dp" from LinearLayout and check.
    – Aniruddha
    Jun 16, 2014 at 10:49
  • Doesn't make any difference. Tried it. Jun 16, 2014 at 11:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.