Android layout TabHost布局中不需要的边距

Android layout TabHost布局中不需要的边距,android-layout,android-tabhost,Android Layout,Android Tabhost,我对安卓系统的开发还不熟悉,但我确实喜欢认为我能很快理解。我一直在为我的垒球队开发一个应用程序。以前我使用过谷歌的appinventor,但是它有很多缺点,所以我现在尝试用Eclipse重新设计它 总之,说到点子上。我似乎有一些多余的填充物被添加到我的线性布局中,我不知道它是从哪里来的 我正在使用TabHost创建顶部的选项卡(谷歌选项卡示例的修改版本) 布局XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout x

我对安卓系统的开发还不熟悉,但我确实喜欢认为我能很快理解。我一直在为我的垒球队开发一个应用程序。以前我使用过谷歌的appinventor,但是它有很多缺点,所以我现在尝试用Eclipse重新设计它

总之,说到点子上。我似乎有一些多余的填充物被添加到我的线性布局中,我不知道它是从哪里来的

我正在使用TabHost创建顶部的选项卡(谷歌选项卡示例的修改版本)

布局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>

我相信这个问题与ScrollView中的android:layout_marginTop=“65dp”有关,但是如果我删除它,我的标签就会消失(我假设我的标签内容只是覆盖在它的顶部)

最后,这里有一个屏幕截图,显示了我正在经历的一个示例(去掉XML字符串,我仍然需要处理这一部分。我只想用数据显示一个示例)。

在从头开始XML并向前迈出一小步之后,我能够重新处理XML并解决布局中多余的填充

我不能100%确定是哪个更改造成了差异,但我怀疑将
相对布局更改为
线性布局
,并将
线性布局
表格布局
移动到
框架布局
之外才是成功的原因

对于可能偶然发现这一点并希望看到我的新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>