【发布时间】:2016-10-27 08:06:33
【问题描述】:
在我的应用程序中,我有一个 webview,它加载一个用户应该执行身份验证的网页。当用户在网页中选择某个输入字段时,webview 应该:
- 专注于领域
- 打开键盘
- 执行向上滚动以便用户继续看到该字段
但是,webview 不会自动向上滚动,因此用户不再看到该字段。如果用户尝试手动滚动,webview 只会做一个小的滚动 - 不足以让用户看到他需要的一切。 问题不在于网页本身,因为当我使用 android chrome 浏览此网页时,它会向上滚动以保持该字段可见并允许滚动到页面底部。我已阅读以下问题: WebView doesn't scroll when keyboard opened 和 adjustPan not preventing keyboard from covering EditText 但答案并没有解决问题。
我当前的activity_web_viewlogin.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/portalWebViewWrapper"
android:orientation="vertical"
tools:context="com.hpe.sb.mobile.app.features.login.activities.WebViewLoginActivity">
<include
android:id="@+id/app_bar"
layout="@layout/app_bar" />
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<WebView
android:id="@+id/portalWebView"
android:layout_below="@id/app_bar"
android:layout_width="match_parent"
android:layout_margin="@dimen/activity_vertical_margin"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</ScrollView>
</LinearLayout>
还尝试了 ScrollView 包含 LinearLayout。
在我的 AndroidManifest.xml 中:
<activity
android:name=".features.login.activities.WebViewLoginActivity"
android:windowSoftInputMode="adjustResize"
android:label="" />
也试过用adjustPan代替adjustResize。
提前致谢!
【问题讨论】:
标签: android webview scrollview