2012-11-26 92 views
4

我有一個tabwidget放置在屏幕的底部,上方有一個webview。當webview加載的網頁內容大於屏幕時,webview將展開以轉換tabwidget - 因爲layout_height在webview中設置爲wrap_content並且它位於滾動視圖中。停止Android webview覆蓋tabwidget

我想要滾動視圖調整到可用的屏幕空間。 我的XML如下:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@android:id/tabhost" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:padding="0dp" > 

    <TabWidget 
     android:id="@android:id/tabs" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_marginBottom="-4dp" 
     android:gravity="top" /> 

    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentTop="true" > 

     <ScrollView 
      android:id="@+id/scroll1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:scrollbars="none" 
      tools:ignore="UselessParent" > 

      <WebView 
       xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/webView1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:gravity="bottom"/> 
     </ScrollView> 

    </FrameLayout> 
</RelativeLayout> 

我已經把一套高度滾動視圖,但正如所預料的,只有精確到某一設備(或多個),不具有普遍性。

任何援助將不勝感激。

+0

具有相同問題的人 - 我回來這一段時間後,並通過簡單地增加一個機器人解決了這個問題:layout_marginBottom值滾動視圖。 – MikeC

+0

您是否嘗試刪除 工具:ignore =「UselessParent」 – baconcheese113

+0

我最初省略了該行,它給了我一個錯誤的種類。 – MikeC

回答

0

使用此XML,它會解決你的問題:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:padding="0dp" > 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" > 

      <ScrollView 
       android:id="@+id/scroll1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:scrollbars="none" 
       tools:ignore="UselessParent" > 

       <WebView 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/webView1" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:gravity="bottom" /> 
      </ScrollView> 
     </FrameLayout> 

     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 

</TabHost>