2012-04-21 80 views
0

我是Android開發的新相對論,但我確實喜歡認爲我趕上了。我一直在重新爲我的壘球隊製作一個應用程序。以前我使用過Google的App Inventor,但遇到了很多不足之處,所以現在我試圖用Eclipse重新使用它。與TabHost佈局不需要的邊距

無論如何,要點。我似乎有一些額外的填充被添加到我的LinearLayout,我不確定它來自哪裏。

我正在使用TabHost在頂部創建標籤(Google標籤示例的修改版本)。

佈局XML:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/main_linlay_parent" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 

    <TabHost 
     android:id="@android:id/tabhost" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     > 

      <RelativeLayout 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@drawable/background" 
       >   

       <!-- Allow the "Tabs" to scroll horizontally --> 
       <HorizontalScrollView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:fillViewport="true" 
        android:scrollbars="none" 
        > 

        <!-- The "Tabs" widget --> 
        <TabWidget 
         android:id="@android:id/tabs" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:background="#000000" 
         /> 

       </HorizontalScrollView> 

       <!-- Provide the "Content" the ability to vertically scroll --> 
       <ScrollView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_marginTop="65dp" 
        > 
        <FrameLayout 
         android:id="@android:id/tabcontent" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         > 
         <LinearLayout 
          android:id="@+id/tabdata" 
          android:orientation="vertical" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          > 
         </LinearLayout> 
        </FrameLayout> 
       </ScrollView> 
      </RelativeLayout> 
    </TabHost> 
</LinearLayout> 

我相信這個問題必須與在滾動型的android:layout_marginTop="65dp",但如果我刪除它,我的標籤消失(我假設我tabcontent只是被疊加在上面)。最後,這裏是一個屏幕截圖,展示了我正在經歷的一個示例(Disreguard XML字符串,我仍然需要按摩該部分,我只是想用數據展示一個示例。)。 http://kahunaball.com/android/screenshot_0.jpg

回答

0

在從頭開始XML並向前邁進了一小步後,我能夠重新處理XML並從我的佈局中解析出多餘的填充。

我不是100%肯定它的變化帶來的變化,但我的懷疑是,改變RelativeLayoutLinearLayout和移動FrameLayoutLinearLayoutTableLayout外面是出了什麼做的伎倆。

對於其他的可以通過這個跌跌想看看我的新的XML從而解決了這個問題,那就是:

<?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="match_parent" 
    android:layout_height="match_parent" > 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/background"> 
     <HorizontalScrollView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fillViewport="true" 
      android:scrollbars="none"> 
      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#000000" /> 
     </HorizontalScrollView> 
     <ScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" > 
      <HorizontalScrollView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:fillViewport="true" 
       android:scrollbars="none" > 
       <FrameLayout 
        android:id="@android:id/tabcontent" 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" > 
        <LinearLayout 
         android:id="@+id/tabdata" 
         android:orientation="vertical" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:gravity="center_horizontal" /> 
        <TableLayout 
         android:id="@+id/myTableLayout" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:background="#33B5E5" /> 
       </FrameLayout> 
      </HorizontalScrollView> 
     </ScrollView> 
    </LinearLayout> 
</TabHost>