久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Android應用程序中WebView中的html文本字段被軟鍵盤

html textfield in WebView in an Android application is hidden by the soft keyboard(Android應用程序中WebView中的html文本字段被軟鍵盤隱藏)
本文介紹了Android應用程序中WebView中的html文本字段被軟鍵盤隱藏的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個 Android 應用程序,它是一個帶有 WebView 的 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>

我嘗試使用 android:windowSoftInputMode="adjustResize" 配置 AndroidManifest.xml 文件,但沒有成功.我還嘗試用 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 behavior - 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 application?

推薦答案

我找到了解決這個問題的方法.(大約在我發布問題一周后;我今天才在 stackoverflow 中回答......)

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

我的代碼中有一些片段改變了 WebView 的高度(為 TabBar 留出空間).事實證明,當您在 WebView 上調用 setLayoutParams 時,即使您設置了 android: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 布局文件中來規避更改 WebView 高度的需要,初始大小為 0.當我增加 TabBar 的大小時,WebView 的大小會自動減小,并保留 android: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.

這篇關于Android應用程序中WebView中的html文本字段被軟鍵盤隱藏的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
主站蜘蛛池模板: 免费在线成人网 | 久久不射网 | 日韩高清www| 97人人超碰 | 少妇av片 | 九九综合 | 亚洲人成在线播放 | 欧美二区乱c黑人 | 日韩免费视频一区二区 | 国产精品久久久久久久久久久久午夜片 | 精品一区二区三 | 中文字幕一区二区视频 | 男人av的天堂 | 色综合一区二区 | 日韩羞羞 | 日韩高清国产一区在线 | 成人一区av偷拍 | 五月天婷婷丁香 | 日韩精品1区2区3区 爱爱综合网 | 亚洲成人激情在线观看 | 成人影院av | 欧美三级视频在线观看 | 久久久久久国产一区二区三区 | 久久精品国产亚洲 | 国产精品视频免费观看 | 97avcc| 国产精品欧美一区喷水 | 国产精品久久久久一区二区三区 | 91中文字幕在线观看 | 中文字幕91av | 国产日韩欧美 | 久久国产福利 | 一区二区三区高清 | 久久国产一区 | 久久高潮 | 超碰网址| 在线播放中文字幕 | 亚洲精品国产成人 | 久久亚洲一区二区三区四区 | 欧美福利精品 | 成人免费小视频 |