Android window doesn't resize/pan when softinput opened from WebView

后端 未结 4 1680
甜味超标
甜味超标 2021-02-18 13:14

My problem is following.

  1. Application uses theme android:Theme.NoTitleBar.Fullscreen and there is only one Activity, all other views are <
相关标签:
4条回答
  • 2021-02-18 13:43

    Okay so this has been an issue from the very beginning and Google hasn't fixed it yet, maybe never. But from the the issue: http://code.google.com/p/android/issues/detail?id=5497 I found potential workaround for this: https://stackoverflow.com/a/19494006/1241783

    I have overridden WebView and I simply added the code for it and it is working well enough to get the window adjusted. It is possible though the code doesn't always work because of various screen heights and might need some adjustments, but in many cases it is working okay and I go with that, since it's the only working solution I have seen.

    0 讨论(0)
  • 2021-02-18 13:59

    Here is what we have done to make it work. As it is by design, FLAG_FULLSCREEN activity won't allow adjusting the views when a keyboard is visible, we took an approach with custom Keyboard Notification Listener and OnTouch listener of Webview.

    KeyboardHelper.java - to find out the keyboard visibility

    Webview Full-Screen Activity Adjustment - To adjust the webview based on the notification and touch point.

    Hope it helps!

    0 讨论(0)
  • 2021-02-18 14:00

    Try this android:isScrollContainer="false" in the ScrollView. According to the Android docx.

    Set this if the view will serve as a scrolling container, meaning that it can be resized to shrink its overall window so that there will be space for an input method

    Hope this will solve your problem

    0 讨论(0)
  • 2021-02-18 14:03

    my code was also not able to resize when keyboard opens.

    <?xml version="1.0" encoding="utf-8"?>
    <WebView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/simple_webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scrollbars="none"
        />
    

    i removed (android:scrollbars="none") statement, and it worked ! So that means the app resizes itself only when the container is scrollable. so by default webview containers scrollable area internally.

    0 讨论(0)
提交回复
热议问题