Reputation: 6357
When I tap on a text field and the keyboard pops up, the upper few fields of my ScrollView hide behind the ActionBar.
If you look at the scrollbar, that is at the very top. That means even if I scroll up now, the elements will not come into view.
I am using ActionBarSherlock. I am not sure if it is the problem with the ABS or with the ScrollView.
Here is the code of my scrollView:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView_MessageUpdate"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MessengerActivity"
android:scrollbarStyle="outsideOverlay"
android:background="@drawable/repeating_bg"
>
<RelativeLayout
android:id="@+id/RelativeLayout_MessageUpdate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center"
android:background="@drawable/repeating_bg"
>
<EditText
android:id="@+id/txtPostedBy"
android:hint="@string/txtPostedByHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="12"
android:inputType="none"
android:layout_marginTop="100dip">
<requestFocus />
</EditText>
<EditText
android:id="@+id/txtPostTitle"
android:hint="@string/txtPostTitleHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txtPostedBy"
android:ems="12"
android:layout_marginTop="3dip"
android:inputType="text">
</EditText>
<EditText android:id="@+id/txtMessage"
android:hint="@string/txtMessageHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="3"
android:gravity="top|left"
android:inputType="textMultiLine"
android:scrollHorizontally="false"
android:layout_alignLeft="@+id/txtPostTitle"
android:layout_alignRight="@+id/txtPostTitle"
android:layout_below="@+id/txtPostTitle"
/>
<EditText android:id="@+id/txtComment"
android:hint="@string/txtCommentHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="5"
android:gravity="top|left"
android:inputType="textMultiLine"
android:scrollHorizontally="false"
android:layout_alignLeft="@+id/txtPostTitle"
android:layout_alignRight="@+id/txtPostTitle"
android:layout_below="@+id/txtMessage"
/>
<Button
android:id="@+id/btnUpdateMessage"
android:text="@string/btnUpdateText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/txtComment"
style="@style/styledBuutonNoIcon_text"
android:background="@drawable/styled_inner_form_button"
android:layout_alignLeft="@+id/txtPostTitle"
android:layout_alignRight="@+id/txtPostTitle"
android:layout_marginTop="3dip" />
<Button
android:id="@+id/btnCancelMessage"
android:text="@string/btnCancelText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btnUpdateMessage"
style="@style/styledBuutonNoIcon_text"
android:background="@drawable/styled_inner_form_button"
android:layout_alignLeft="@+id/txtPostTitle"
android:layout_alignRight="@+id/txtPostTitle"
android:layout_marginTop="3dip" />
<!--
<Button
android:text="@string/btnDeleteText"
android:id="@+id/btnDeleteSchool"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btnCancelSchool"
style="@style/styledBuutonNoIcon_text"
android:background="@drawable/styled_inner_form_button"
android:layout_alignLeft="@+id/txtSchoolWebsite"
android:layout_alignRight="@+id/txtSchoolWebsite"
android:layout_marginTop="3dip"
/>
-->
</RelativeLayout>
</ScrollView>
Upvotes: 1
Views: 2713
Reputation: 3012
I solved the same problem by removing "center" in the main layout
android:layout_gravity="center"
android:gravity="center"
Upvotes: 1
Reputation: 5549
Set android:windowSoftInputMode
of your activity in AndroidManifest.xml
to "adjustPan"
.
According to Documentation:
The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing.
Upvotes: 3