2012-11-26 183 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>