ymutlu
ymutlu

Reputation: 6715

ScrollView does not respond to keyboard

I have a problem with EditText scroll behaviour in ScrollViews, normally it scrolls up content inside scroll if keyboard opens over it. But if you fill the layout inside the scrollview dynamically, keyboard push up whole screen, anyone else had this problem before. Thanks in advance.

<ScrollView
    android:id="@+id/scroll_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/header_area" >

        <LinearLayout
            android:id="@+id/contentHolder"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
        </LinearLayout>
</ScrollView>

This sample works normal, linear layout scrolls in scroll view but it shows scrolls even keyboard closed. I can not use fixed heights.

 <ScrollView
        android:id="@+id/scroll_view"
        android:layout_width="fill_parent"
        android:layout_height="100dip"
        android:layout_below="@+id/header_area" >

            <LinearLayout
                android:id="@+id/contentHolder"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >
            </LinearLayout>
    </ScrollView>

I have tried xml below, it works as expected on a new project but push up window in my project. I have found some other people having this problem, I'll share solution asap i found it.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">


    <RelativeLayout
        android:id="@+id/header_area"
        android:layout_width="match_parent"
        android:layout_height="50dip" >
    </RelativeLayout>

    <ScrollView
        android:id="@+id/scroll_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <LinearLayout
            android:id="@+id/contentHolder"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
            <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
            <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
            <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
            <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
            <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
        </LinearLayout>
    </ScrollView>

</LinearLayout>

Upvotes: 1

Views: 1928

Answers (2)

ymutlu
ymutlu

Reputation: 6715

<application
    android:icon="@drawable/is_logo_iphone"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >

Problem is "Fullscreen" theme does not support resize. Using

    android:theme="@android:style/Theme.Black.NoTitleBar"

solves the problem.
Thanks for answers.

Upvotes: 2

Warpzit
Warpzit

Reputation: 28162

That is because your scrollview is resizeable. Try to set the height of your scrollview to match_parent instead.

Try also setting android:fillViewport="true" inside your scrollview.

Also you wouldn't happen to have added something like following within your activity tag of your manifest: android:windowSoftInputMode="adjustResize" That would pretty much ruin all our effort. If you have following within the manifest remove it.

Your probably have to configure your manifest. Here is a list of possible configurations for soft keyboard. It might be android:windowSoftInputMode="adjustPan" you want to use.

Upvotes: 0

Related Questions