Android 如何删除Tabhost的边框

Android 如何删除Tabhost的边框,android,android-launcher,Android,Android Launcher,我想要一个没有白色部分的全屏 所以红线在哪里,我想要我的Tabhost 有可能有一个全屏布局吗?没有白色的部分 如果是这样,下面是图片: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">

我想要一个没有白色部分的全屏

所以红线在哪里,我想要我的Tabhost

有可能有一个全屏布局吗?没有白色的部分

如果是这样,下面是图片:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TabHost
android:id="@+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" >

    <HorizontalScrollView android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:scrollbars="none">

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:background="#191919" />

    </HorizontalScrollView>

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

        <TextView
            android:id="@+id/tab1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textColor="#FFFFFF"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/tab2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"  />

        <TextView
            android:id="@+id/tab3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"  />

        <TextView
            android:id="@+id/tab4"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"  />

        <TextView
            android:id="@+id/tab5"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"  />

        <TextView
            android:id="@+id/tab6"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"  />

        <TextView
            android:id="@+id/tab7"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"  />

    </FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>

这是我的布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TabHost
android:id="@+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" >

    <HorizontalScrollView android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:scrollbars="none">

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:background="#191919" />

    </HorizontalScrollView>

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

        <TextView
            android:id="@+id/tab1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textColor="#FFFFFF"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/tab2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"  />

        <TextView
            android:id="@+id/tab3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"  />

        <TextView
            android:id="@+id/tab4"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"  />

        <TextView
            android:id="@+id/tab5"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"  />

        <TextView
            android:id="@+id/tab6"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"  />

        <TextView
            android:id="@+id/tab7"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"  />

    </FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>

dimens.xml

<resources>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="nav_header_vertical_spacing">16dp</dimen>
    <dimen name="nav_header_height">160dp</dimen>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>
    <dimen name="fab_margin">16dp</dimen>
</resources>

16dp
160dp
16dp
16dp
16dp

尝试设置顶级活动布局的0dp。我在代码中直接设置为“0dp”来显示,但使用“res/values/dimens.xml”(维度资源)文件更好地设置这些值适用于相对布局和线性布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="fill_horizontal|center_horizontal"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp" >

您需要删除这些行:

android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
哪些(值)来自
dimens.xml
文件


让我们提到它,这不是你的
活动的完整代码,这只是你参考另一个
布局的内容。xml

你可以尝试将android:padding=“0dp”放在最外层的线性布局中,并使用match\u parent而不是fill parent,或者尝试放负数padding。例如:
-16dp
我试过了,但是TabHost正好在这个不可见的框架上:(顺便说一下,
fill\u parent
大约在5年前就被弃用了。改用
match\u parent
。在values文件夹中,你看到(dimens.xml)了吗文件??如果您这样做,请在Q中发布以检查为什么
sp
而不是
dp
?您不应将sp用于版面大小、填充或边距。sp仅用于文本大小。