本文介绍了隐藏在Android Webview键盘下方的输入文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Fragment的应用程序中实现Webview,但在Webview的EditText字段中实现,出现键盘时隐藏.
I implement Webview in my app in Fragment but in Webview EditText Field Hide when the keyboard appears.
我设置了
WindowSoftInputMode = SoftInput.StateHidden | SoftInput.AdjustResize
和android:fitsSystemWindows="true"
但不为我工作.
我也使用自定义RelativeLayout
,但是它不起作用.
I also use custom RelativeLayout
but it's not working.
请帮助我解决此问题.
我的代码在片段下面
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:orientation="vertical"
android:fillViewport="true">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
some layout and label
<RelativeLayout
android:id="@+id/reletivePurchaseWebview"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:visibility="gone"
android:layout_height="match_parent"
android:layout_width="match_parent">
<android.webkit.WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:layout_above="@+id/lblBuyMore"
android:id="@+id/webView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="25dp"
android:layout_centerHorizontal="true"
android:id="@+id/lblBuyMore"
android:layout_alignParentBottom="true"
app:fontFamily="@font/lato_medium"
android:gravity="center_vertical"
android:text="abc"
android:textColor="#24E5BA"
android:textSize="@dimen/textSize_11" />
</RelativeLayout>
</RelativeLayout>
</ScrollView >
推荐答案
当我尝试复制您的问题时,android studio抱怨的第一件事是
While I was trying to replicate your problem the first thing android studio complained was
我建议您按照以下说明更新布局,然后重试.
I would suggest you to update your layout as following and try again.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" // <-- Added this
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical"
android:scrollbars="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" // <-- Updated this
android:orientation="vertical">
//some layout and label
<RelativeLayout
android:id="@+id/reletivePurchaseWebview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:visibility="gone">
<android.webkit.WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/lblBuyMore"
android:scrollbars="vertical" />
<TextView
android:id="@+id/lblBuyMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center_vertical"
android:padding="25dp"
android:text="abc"
android:textColor="#24E5BA"
android:textSize="@dimen/textSize_11"
app:fontFamily="@font/lato_medium" />
</RelativeLayout>
</RelativeLayout>
清单:
android:windowSoftInputMode="adjustPan" >
这篇关于隐藏在Android Webview键盘下方的输入文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!