views:

613

answers:

1

In my layout, there is a TextView at the bottom of the screen. The problem is that when I click inside the text box to type something, the keyboard covers the text box as a result of which I am not able to see what's happening... Is there any solution for this? Here's my layout...

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

    <ImageView 
       android:id="@+id/headerimg"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_gravity="left"
           android:paddingTop="5dp"
           android:paddingBottom="5dp"
           android:paddingLeft="5dp"
           android:src="@drawable/header_image"
          />
    <LinearLayout 
    android:id="@+id/secondaryLayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="320dip"
    android:layout_marginTop = "5dip"
    android:layout_marginLeft="8dip"
    android:layout_marginRight="8dip"
    android:cacheColorHint="#00000000"
    >
    <!-- A ListView appears here -->
    </LinearLayout>

    <RelativeLayout 
    android:id="@+id/message"
    android:orientation="horizontal"
    android:layout_width="300dip"
    android:layout_height="80dip"
    android:layout_gravity="center"
    >
     <EditText
      android:id="@+id/MessageText"
      android:layout_height="wrap_content"
      android:layout_width="230dip"
      android:layout_marginLeft="8dip"
      android:layout_marginTop = "8dip"
      android:paddingBottom = "8dip"
      android:paddingLeft="15px"
      android:hint="Type something here...">
     </EditText>
     <Button
      android:id="@+id/MsgButton"
      android:layout_margin="0dip"
      android:layout_width="48dip"
      android:layout_toRightOf="@id/MessageText"
      android:layout_height="48dip">
     </Button>
    </RelativeLayout>     
</LinearLayout>
+2  A: 

You should be able to control that in the manifest file, by adding android:windowSoftInputMode="adjustPan" attribute to the activity element. See windowSoftInputMode documentation and a blog post explaining this in more detail.

Heikki Toivonen
This looks like the right way to go. I tried something else when I had the same problem. I put the entire layout inside a scroll view. So when the soft keyboard is visible the scrollbars adjust themselves, thus making the bottom most widgets visible. This might be a crude hack, it worked FWIW.
Jayesh