在我的应用中,我有一个WebView来加载一个网页,用户需要在该网页上执行身份验证。当用户选择网页中的某个输入字段时,WebView 应该:
我的当前 activity_web_viewlogin.xml:
- 聚焦于该字段
- 打开键盘
- 执行向上滚动,以便用户可以继续看到该字段
我的当前 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。
提前感谢!
ScrollView
中流畅地使用ConstraintLayout
。 - Lalit Fauzdar