我在我的 Android 应用程序中使用 WebView。我想显示一个具有 EditTest 的网站。当我运行我的应用程序时,它运行良好,但是当我单击 EditText 时,我的键盘打开,并且我的 WebView 不调整大小。 这是我的 .xml 文件
<android.support.v4.widget.DrawerLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".FacebookNewWrapper" >
<!-- Our actual WebView -->
<RelativeLayout
android:id="@+id/webview_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.facebook.FacebookWebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fadeScrollbars="true"
android:focusable="true"
android:focusableInTouchMode="true" />
<!-- Progress bar used to show the loading progress -->
<ProgressBar
android:id="@+id/progress_bar"
style="@style/Widget.Tinfoil.ProgressBar"
android:layout_width="fill_parent"
android:layout_height="@dimen/webview_top_progress_bar"
android:layout_alignParentTop="true" />
</RelativeLayout>
<!-- Mostly use for full-screen video playback -->
<FrameLayout
android:id="@+id/fullscreen_custom_content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/black"
android:visibility="gone" />
<!-- Menu drawer (right) -->
<include layout="@layout/drawer_menu" />
我已添加
android:configChanges="orientation|keyboardHidden"
android:launchMode="standard"
android:windowSoftInputMode="adjustPan"
将其放入我的 Android Menifest.xml 中 并将其添加到我的 .java 文件中
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
但没有什么对我有帮助。 我该如何解决我的问题。
最佳答案
从 .java 文件中删除
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
在 Android Manifest.xml 中查找
android:windowSoftInputMode="adjustPan"
更改为
android:windowSoftInputMode="adjustResize"
关于java - 键盘打开时 WebView 调整屏幕大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28517980/