Thursday, May 20, 2010

[android-developers] Pushing up views above soft keyboard

hi,

I am trying to push up the views in my activity whenever a soft
keyboard comes up. I have been partially successful in this, except
that certain views remain hidden behind the soft keyboard.

My XML looks like the below. I am specifying the last RelativeLayout
RL3 containing buttons with the attribute:
android:layout_alignParentBottom="true" so that they stay above the
soft keyboard when it comes up. However. the scrollview SV1 which is
above the last RelativeLayout RL3 is not scrolling up completely and
so a part of the scroll view remains hidden behind the soft keyboard.
I have tried to set paddingBottom=70px but that still does not make
the scroll view go up. Any ideas why this is happening?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg1">

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

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="70dip">

<RelativeLayout android:id="@+id/RL1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
[....]
<RelativeLayout android:id="@+id/RL2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/TV1" >
[....]
</RelativeLayout>

</RelativeLayout>

<EditText android:id="@+id/RT1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/RL2"/>

</RelativeLayout>

</ScrollView>

<RelativeLayout android:id="@+id/RL3"
android:background="@drawable/BG4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">

<Button android:id="@+id/BT1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"/>

<Button android:id="@+id/BT2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"/>

</RelativeLayout>

</RelativeLayout>

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment