2016-01-23 58 views
3

我想拥有一个全屏没有白色部分如何删除Tabhost的边框

所以,红线是我想要我的Tabhost。

是否可以拥有全屏布局?没有白色的部分?

如果是这样,这里是图片:

Picture

这是我的布局:

<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> 
+0

你可以尝试把android:padding =“0dp”作为最外层线性布局,并使用match_parent来代替填充父项 –

+1

或者尝试把**负**填充。即:'-16dp' –

+0

我试过这个,但是比TabHost正好在这个看不见的框架:( – TryHard

回答

0

尝试设置顶级Activity Layout的0dp。我直接在代码中设置为'0dp'来显示,但使用'res/values/dimens.xml'(维度资源)文件更好地设置这些值。 适用于RelativeLayout和LinearLayout

<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" > 
+3

为什么'sp'而不是'dp'? – ataulm

+1

您不应该将SP用于布局大小,填充或边距。 SP仅用于文本大小。 – Mike

1

您需要删除这些行:

android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 

将对(值)来自dimens.xml文件。

让我们来提一下它,这不是你的Activity的完整代码,这只是你指向另一个Layout.xml的内容。