Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page scroll when soft keyboard popped up

I have a <ScrollView> layout:

<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/my_scrollview"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     >      <LinearLayout         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:orientation="vertical" >          <EditText             android:id="@+id/input_one"             android:layout_width="300dp"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:inputType="number" >           <EditText             android:id="@+id/input_two"             android:layout_width="300dp"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:inputType="number" >           <EditText             android:id="@+id/input_three"             android:layout_width="300dp"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:inputType="number" >            <Button             android:id="@+id/ok_btn"             android:layout_width="200dp"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:layout_marginTop="20dp"             android:text="@string/ok_str" />        </LinearLayout> </ScrollView> 

As you see above, the simple layout consists of three input fields and an "Ok" button.

I run my app with the above layout, when I tap on the 1st input field (@+id/input_one), the soft keyboard will pop up from the bottom of the screen, it hides the 3rd input field and the "Ok" button.

Since I use <ScrollView> , I thought I can scroll the page up in order to see the 3rd input field and "Ok" button which are hidden by the soft keyboard, but the page is not scrollable. Why? How to get rid of it? basically, i would like to see every input fields and "Ok" button even the soft keyboard popped up.

like image 766
Leem.fin Avatar asked Apr 03 '12 07:04

Leem.fin


People also ask

How do I scroll up layout when clicking on Edittext?

try this android:windowSoftInputMode="adjustResize" in your activity in manifest file.


1 Answers

I fixed the problem by defining the following attribute in <activity> of AndroidManifest.xml

android:windowSoftInputMode="adjustResize" 
like image 143
Leem.fin Avatar answered Sep 18 '22 23:09

Leem.fin