我有一個Android應用程序,它是一個帶有WebView的TabHost。我用它來加載一個特定的html文件,它的底部有一個文本字段。在Android應用程序的WebView中的HTML文本字段被軟鍵盤隱藏
當我觸摸html文本框時,彈出軟鍵盤並隱藏文本框,以便我看不到我輸入的內容。
這裏的佈局:
<?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。
我注意到,android的網絡瀏覽器有一個漂亮的行爲 - 在網頁中,彈出軟鍵盤後,網頁平滑滾動,以便用戶可見焦點文本框。我如何在我的應用程序中有這種行爲?
解決此問題的方法可能會在軟鍵區出現時得到通知,然後手動調整webview的大小。 我已嘗試在所有佈局類中實現onCreateInputConnection(EditorInfo),但鍵盤出現時無法獲得通知。 幫助! – gardenofwine 2010-04-29 07:44:48