2011-02-10 108 views
1

我想模仿默認的android瀏覽器的行爲 - 一旦用戶向下滾動,頂部的EditText(地址欄)將開始「消失」。我現在唯一能想到的就是將EditText和WebView放在ScrollView中,但這會產生其他問題,不推薦使用。Android:在WebView之上的EditText?

您認爲如何?

回答

0

通過擴展WebView並覆蓋onScrollChanged()來創建自定義視圖。通過一些計算,你可以完成你的任務。

+0

所以基本上你說的是,我將不得不「推」地址欄超出屏幕的界限?有沒有「優雅」的方式來做到這一點? – Alex1987 2011-02-10 14:31:23

+0

這就是我所暗示的。根據當前滾動更改編輯框的位置。 沒有,我知道。 – 2011-02-10 14:39:52

0

ScrollView會導致什麼問題?這應該工作得很好:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:stretchColumns="0" android:orientation="vertical"> 

<ScrollView android:layout_width="fill_parent" android:layout_gravity="top" android:layout_height="fill_parent"> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:stretchColumns="0" android:orientation="vertical"> 
<EditText android:layout_width="fill_parent" android:id="@+id/editText1" android:text="yourtexthere" android:layout_gravity="bottom" android:layout_height="wrap_content"> 
</EditText> 
    <WebView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/myWebView"></WebView> 
</LinearLayout> 
</ScrollView> 

</LinearLayout>