2014-09-29 73 views
0

我試圖添加一個應該與它一起滾動的Web視圖上方的視圖。 香港專業教育學院試圖把兩種觀點滾動型裏面是這樣的:如何在webview上方添加一個視圖,它將與它一起滾動?

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:background="@android:color/black" /> 

     <WebView 
      android:id="@+id/webview" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </LinearLayout> 
</ScrollView> 

它工作得很好,直到香港專業教育學院遇到了的WebView它首先使前後發生了改變它的大小的情況下的問題(即,如果加載的URL使用延遲加載在其一些組件上)。 順便說一句,如果scroll \ Linear \ Web視圖的高度或寬度設置爲「match_parent」或「wrap_content」,則無關緊要。我仍然遇到同樣的問題。

我也試過使用「hidden」setEmbeddedTitleBar(View v)方法,該方法是從Android的WebView中引入的,然後將其從Android的WebView中移除,以便在WebView上方簡單添加視圖而不需要包裝滾動視圖。 我嘗試了一些在這裏建議的黑客,但我沒有找到有效的東西。

有沒有人遇到過這個問題,並找到了實現這個目標的成功方法?

非常感謝!

+0

網頁視圖和你的整個活動的滾動條滾動不干預? – Darpan 2014-09-30 09:30:54

+0

不,滾動視圖僅處理滾動事件,所有其他事件(如按下Web視圖中的鏈接或視頻)均可正常工作。 – BorisK 2014-09-30 15:09:23

+0

參考這篇文章,http://stackoverflow.com/q/43533068/6521116 – 2017-05-08 05:32:45

回答

0

嘗試添加一些權重的佈局是這樣的:

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="100dp" 
     android:layout_weight="0" 
     android:background="@android:color/black" /> 

    <WebView 
     android:id="@+id/webview" 
     android:layout_weight="1" 
     android:background="@color/brand_color" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" /> 
</LinearLayout> 
+0

試過了,它沒有工作不幸。 – BorisK 2014-09-30 07:17:23

相關問題