2015-04-24 3 views
1

У меня есть пространство между моими вкладками. Я просмотрел все возможные решения на StackOverflow и добавил их, но между ними существует пространство.Пробел между вкладками в Android

вкладки Моего код:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="0dp" 
    android:layout_weight="1" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:padding="0dp" 
    > 

    <ImageView 
     android:id="@+id/tab_image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     /> 

</LinearLayout> 

Моих Компоновка с закладками:

<?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="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

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

     <FrameLayout 
      android:id="@+id/tab5" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" /> 

     <FrameLayout 
      android:id="@+id/tab4" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" /> 

     <FrameLayout 
      android:id="@+id/tab3" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" /> 

     <FrameLayout 
      android:id="@+id/tab2" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" /> 

     <FrameLayout 
      android:id="@+id/tab1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" /> 
    </FrameLayout> 

    <TabWidget 
     android:id="@android:id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:layout_weight="0" 
     android:background="@drawable/bottom_image" 
     android:dividerPadding="0dp" 
     android:fitsSystemWindows="true" 
     android:gravity="fill" 
     android:showDividers="none" 
     android:tabStripEnabled="false" 
     android:visibility="visible" > 
    </TabWidget> 
    </LinearLayout> 

</TabHost> 

Я добавил следующее в коде, а также:

mTabHost.getTabWidget().setStripEnabled(false); 
mTabHost.getTabWidget().setDividerDrawable(null); 
if (Integer.parseInt(Build.VERSION.SDK) >= Build.VERSION_CODES.HONEYCOMB) { 
    mTabHost.getTabWidget().setShowDividers(LinearLayout.SHOW_DIVIDER_NONE); 
} 

Но всем это показывает пространство между вкладками , Я что-то упускаю?

ответ

0

У меня нет шансов проверить их с помощью IDE Android. но я полагаю, что это сработает.

<?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="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

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

    <FrameLayout 
     android:id="@+id/tab5" 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="20.0" /> 

    <FrameLayout 
     android:id="@+id/tab4" 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="20.0" /> 

    <FrameLayout 
     android:id="@+id/tab3" 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="20.0" /> 

    <FrameLayout 
     android:id="@+id/tab2" 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="20.0" /> 

    <FrameLayout 
     android:id="@+id/tab1" 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="20.0" /> 
</FrameLayout> 

<TabWidget 
    android:id="@android:id/tabs" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom" 
    android:layout_weight="0" 
    android:background="@drawable/bottom_image" 
    android:dividerPadding="0dp" 
    android:fitsSystemWindows="true" 
    android:gravity="fill" 
    android:showDividers="none" 
    android:tabStripEnabled="false" 
    android:visibility="visible" > 
</TabWidget> 

Здесь я дал weightSum = 100.0 и разделить это эквивалентно всем Чайлдс.

+0

Если я не добавлю андроида: layout_weight = "20" в tabcontent FrameLayout, он не отображает вкладки. – JourneyWithAndroid