【问题标题】:Webview not resizing when keyboard appears出现键盘时Webview没有调整大小
【发布时间】:2015-02-13 09:21:30
【问题描述】:

当键盘出现时,需要调整我的 webview 的大小,类似于 Cordova/Phonegap。 现在按照下面的代码,我的输入文本字段被设备键盘覆盖。我想挤压 webview 的高度并使其调整设备键盘上方的高度。

活动代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_home">

<include android:id="@+id/head" layout="@layout/header" />

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="11dp"
    android:layout_marginLeft="11dp"
    android:layout_marginRight="11dp"
    android:layout_marginTop="2dp"
    android:layout_below="@id/head"
    android:background="@drawable/overlay_bg2"
    android:orientation="vertical"
    android:padding="9dp" >

    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:layout_gravity="center"
        android:isScrollContainer="true"/>

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleLargeInverse"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:visibility="invisible" />

</FrameLayout>

</RelativeLayout>

清单条目:
主题android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"


活动键盘控制android:windowSoftInputMode="adjustResize"

【问题讨论】:

  • 改用android:windowSoftInputMode="adjustResize|stateHidden
  • 不,没有用。我需要将整个 webview 布局压缩到键盘上方的区域
  • 阅读this并选择您需要的@Abhinav Tyagi
  • 它不工作。我尝试过状态和调整的不同组合。科尔多瓦是怎么做到的???
  • 这家伙正在使用 Cordova.... link 不知道是不是你想要的

标签: android cordova webview android-softkeyboard


【解决方案1】:

据我所知,如果您的活动(或整个应用程序)设置为全屏; android:windowSoftInputMode="adjustResize" 不起作用。

【讨论】:

  • 有什么解决办法吗?
  • 确保您没有在 webview 中使用绝对位置的 css。
猜你喜欢
  • 1970-01-01
  • 2015-08-21
  • 1970-01-01
  • 2013-04-09
  • 1970-01-01
  • 2017-05-03
  • 2017-07-25
  • 2020-01-29
相关资源
最近更新 更多