android - How to push Activity content up when Keyboard activated -


in activity of application, user has submit many strings trough edittext , button. range of submits can go minimum of 9 maximum of 24, want process easy , fast possible.

i thinking making keyboard visible while whole activity content gets pushed up.


i have tried use following rule in manifest make push activity android:windowsoftinputmode="adjustresize" looks pushes content marginbottom.

any ideas bout how achieve this?

edit:

the following xml code of layout of activity:

<?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" android:fillviewport="true">  <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="wrap_content" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.fet.leonardo.scurcola.nameselection" android:background="#e0ab18">  <textview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="@string/whomaster"     android:textcolor="@color/white"     android:textsize="50sp"     android:layout_margintop="50dp"     android:textalignment="center"     android:id="@+id/whomaster"     android:layout_alignparenttop="true"     android:layout_centerhorizontal="true" />  <edittext     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:inputtype="textpersonname"     android:hint="@string/master"     android:ems="10"     android:textcolorhint="@color/white"     android:textcolor="@color/white"     android:textcolorhighlight="@color/white"     android:id="@+id/names"     android:layout_centervertical="true"     android:layout_centerhorizontal="true" />  <button     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:id="@+id/next"     android:layout_marginbottom="50dp"     android:onclick="addplayer"     android:text="@string/next"     android:layout_alignparentbottom="true"     android:layout_alignend="@+id/names"     android:textcolor="#e0ab18" />  <button     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="@string/back"     android:id="@+id/back"     android:enabled="false"     android:onclick="removeplayer"     android:textcolor="#e0ab18"     android:layout_marginbottom="50dp"     android:layout_alignparentbottom="true"     android:layout_alignstart="@+id/names" />  <button     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:id="@+id/finish"     android:visibility="gone"     android:text="@string/finish"     android:layout_alignparentbottom="true"     android:layout_alignend="@+id/names"     android:layout_marginbottom="50dp"     android:onclick="tonextactivity"     android:textcolor="#e0ab18"/>  <textview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="@string/zero"     android:textsize="50sp"     android:textcolor="@color/white"     android:id="@+id/playersleft"     android:layout_below="@+id/names"     android:layout_centerhorizontal="true"     android:layout_margintop="50dp" />  </relativelayout> </scrollview> 

apart setting option android:windowsoftinputmode="adjustresize", can try using scrollview

having many fields can have downside application speed - since every single element has drawn , can expensive. in turn affect ui thread , cause app crashing.

using scrollview, can able scroll , down through edittext elements.

to speed application loading, example if have lot more edittexts, can load half elements/widgets when activity loaded , once user has started typing first field, load rest.

this approach have used several times , should work fine!

good luck , please let me know if helps!

update

to have scrollable view, make root layout scrollview - remember can have 1 child.

<scrollview     ....    ....    ..... >     <relativelayout       ....       ....       ..... >        <edittext />       ...    </relativelayout>  </scrollview> 

so, have scrollview root! enable scroll view , have keyboard below or @ bottom!


Comments