user1136875
user1136875

Reputation: 613

Android scroll view - need to scroll when keyboard is shown - although data is less than 1 page

I have an activity showing data on the screen that is less than 1 total page. Therefore, when I press on an editbox on the screen, the keyboard hides the UI components (below it).

Problem is that scrolling is not enabled (because of the amout of data). How can I force the scrolling?

Upvotes: 1

Views: 1272

Answers (1)

Benito Bertoli
Benito Bertoli

Reputation: 25793

You should surround your layout with a ScrollView.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <EditText
           android:id="@+id/editText1"
           android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:inputType="text" >

            <requestFocus />
        </EditText>
    </LinearLayout>
</ScrollView>

Upvotes: 1

Related Questions