Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Soft keyboard not pushing webview content up neither resizing

Tags:

android

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.

like image 365
Fred Avatar asked Mar 27 '15 09:03

Fred


People also ask

What is windowSoftInputMode?

The soft keyboard can be configured for each activity within the AndroidManifest. xml file using the android:windowSoftInputMode attribute to adjust both default visibility and also how the keyboard affects the UI when displayed.


1 Answers

I tried:

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

adjustResize solved the problem.

like image 178
Alp Altunel Avatar answered Sep 23 '22 11:09

Alp Altunel