7

Put simply, after loading the content in a webview and tapping on a text field, my app refuses to resize or pan.

Here's my setup

I have a single Activity with multiple fragments. Here's the layout with the container for the fragment.

 <android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"      
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent" 
    android:layout_height="match_parent">
    <!-- MAIN CONTENT -->
    <FrameLayout 
       android:id="@+id/container"
       android:layout_width="match_parent"
       android:layout_height="match_parent"   
       android:background="@android:color/white" />

    <RelativeLayout
       android:layout_width="240dp"
       android:layout_height="match_parent"
       android:layout_gravity="start">

       <!-- ... -->
    </RelativeLayout>
</android.support.v4.widget.DrawerLayout>

Here's the webview fragment's layout.

<RelativeLayout   
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include
        android:id="@+id/tbOnlinePayment"
        layout="@layout/toolbar" />

    <WebView
        android:layout_below="@+id/tbOnlinePayment"
        android:id="@+id/paymentWebView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <ProgressBar
        android:id="@android:id/progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"/>

</RelativeLayout>

My app's theme extends Theme.AppCompat.Light.DarkActionBar

what I've tried:

  • Like it's written all over the web I tried both android:windowSoftInputMode="adjustResize" and android:windowSoftInputMode="adjustPan".
  • I know in fullscreen the android:windowSoftInputMode="adjustResize" won't work, but I don't force this manually. I placed here the app's theme, because maybe someone knows this theme somehow forces fullscreen.
  • Building on the assumption above I added <item name="android:windowFullscreen">false</item> to the app's theme, but still no result.
  • Wrapping the webview in a scrollview.
  • Changing the webview's height to wrap_content.
  • Basically went through most of the SO posts and solutions.

What I want:

I don't really care if the webview is resized or pushed up. What I want is the keyboard not to hide the input fields.

Fred
  • 16,367
  • 6
  • 50
  • 65
  • 1
    Try "android:windowSoftInputMode="adjustResize" in the Android Manifest file and using the meta tag "height=device-height" in your html DOM. – atulkhatri Mar 27 '15 at 09:48
  • Also try android:windowSoftInputMode="adjustNothing" – atulkhatri Mar 27 '15 at 09:49
  • 1
    I also had `android:theme="@android:style/Theme.NoTitleBar.Fullscreen"` which prevented `adjustResize` from working. Using just `android:theme="@android:style/Theme.NoTitleBar"` made `adjustResize` work. Ultimately that worked with this answer: http://stackoverflow.com/a/14565884/221458 – Gady Aug 11 '15 at 01:04

1 Answers1

2

I tried:

    <activity
        android:name="com.myapp.MainActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustResize">

adjustResize solved the problem.

Alp Altunel
  • 3,324
  • 1
  • 26
  • 27