I have an Activity that consists of a large scrollview (that contains EditText fields) along with a button that is anchored to the bottom of the screen (not part of the scrollView). This is a simple example to display the issue I am seeing. The manifest for my app specifies android:windowSoftInputMode = adjustPan for all Activities.
If I run this Activity directly, everything is displayed correctly and the scrollview scrolls between the edit fields as it should.
I don’t have enough points to post images or >2 hyperlinks…..
If I run this Activity as the content of a TabHost, the scrolling seems to be borked. Whenever an EditText gains focus, the activity properly pans to the Edit field. However, it also forces the button onto the screen.
Inside TabHost – edit first field – Where did that button come from
I have tried creating the layout for this Activity using a LinearLayout (with negative margin for the button) as well as a RelativeLayout, and both exhibit the same issue with the button always being visible when scrolling through the 3 EditText fields.
Has anyone seen anything like this before or have any idea how to get the scrolling to work properly inside the TabHost ?????
LinearLayout version
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="60dip"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<EditText android:id="@+id/e1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dip"
android:layout_marginBottom="30dip"
android:hint="edit text 1"
/>
<EditText android:id="@+id/e2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dip"
android:layout_marginBottom="30dip"
android:hint="edit text 2"
/>
<EditText android:id="@+id/e3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dip"
android:layout_marginBottom="30dip"
android:hint="edit text 3"
/>
</LinearLayout>
</ScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_marginTop="-60dip"
android:layout_gravity="center"
/>
RelativeLayout Version
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
/>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_above="@+id/button1"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<EditText android:id="@+id/e1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dip"
android:layout_marginBottom="30dip"
android:hint="edit text 1"
/>
<EditText android:id="@+id/e2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dip"
android:layout_marginBottom="30dip"
android:hint="edit text 2"
/>
<EditText android:id="@+id/e3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dip"
android:layout_marginBottom="30dip"
android:hint="edit text 3"
/>
</LinearLayout>
</ScrollView>
Thanks in advance.
In case this helps someone else…..
All the Activities that were hosted inside the TabHost had android:windowSoftInputMode = adjustPan.
However, the Activity that hosted the TabHost was missing android:windowSoftInputMode = adjustPan.
Once I added that, the panning worked the smae inside a TabHost or outside the TabHost.