L文本字段中的WebView在Android应用程序是隐藏软键盘

L文本字段中的WebView在Android应用程序是隐藏软键盘

本文介绍了HTML文本字段中的WebView在Android应用程序是隐藏软键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android应用程序,它是一个web视图一个TabHost。我用它来加载在其底部的文本字段中的特定HTML文件。

I have an Android application that is a TabHost with a WebView. I use it to load a specific html file that has a text field in its bottom part.

在我接触的HTML文本框,软键盘弹出,并隐藏文本框,让我看不到我所输入的。

When I touch the html textfield, the soft keyboard pops up, and hides the textfield, so that I cannot see what I have typed.

下面的布局:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/main"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
        <TabWidget
            android:focusableInTouchMode="false"
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="63dp" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/layout"
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
                <WebView
                    android:id="@+id/webview"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1" />
            </LinearLayout>
        </FrameLayout>
    </LinearLayout>
</TabHost>

我试图配置AndroidManifest.xml文件与安卓windowSoftInputMode =adjustResize没有成功。我也曾尝试与 ScollView 替换的FrameLayout 在我的布局,但引起我的的WebView 当应用程序运行。这可能是由于一些的JavaScript 我在页面上已经运行在规模上无限增加。

I have tried to configure the AndroidManifest.xml file with android:windowSoftInputMode="adjustResize" with no success. I have also tried replacing the FrameLayout in my layout with ScollView, but that caused my webview to increase in size indefinitely when the application is running.. this may be due to some javascript I have running on the page.

我已经注意到了Android的网络浏览器有一个漂亮的行为 - 在网页中,后软键盘弹出,网页滚动流畅,这样可获得焦点文本框是对用户可见。我怎么能有这种行为在我的应用程序了?

I have noticed that the android's web browser has a nifty behaviour - in a web page, after the soft keyboard pops up, the web page scrolls smoothly so that the focusable textfield is visible to the user. How can I have this kind of behavior in my applicaiton?

推荐答案

我发现这个问题的解决方案。 (大约一个星期后,我贴的问题,我只得到了计算器中今天在回答......)

I found a solution for this issue. (about a week after I posted the question; I only got to answering in stackoverflow today...)

我在我的code片,改变web视图的高度(有余地的TabBar)。原来,当你调用一个的WebView setLayoutParams,它将不再改变其高度,即使你有机器人:windowSoftInputMode =adjustResize设置

I had pieces in my code that changed the WebView's height (to have room for a TabBar). Turns out that when you invoke setLayoutParams on a WebView, it will no longer change its height even if you have android:windowSoftInputMode="adjustResize" set.

我规避了需要加入的TabBar到main.xml中布局文件,与0的初始大小。当我增加的TabBar的大小来改变的WebView的身高,web视图的大小自动降低,而且preserves在机器人:windowSoftInputMode =adjustResize的行为

I circumvented the need to change the WebView's height by adding the TabBar to the main.xml layout file, with an initial size of 0. When I increase the TabBar's size, the WebView's size decreases automatically, and it preserves the android:windowSoftInputMode="adjustResize" behavior.

这篇关于HTML文本字段中的WebView在Android应用程序是隐藏软键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 22:18