Как убрать расстояние между вкладками в Android-приложении?

У меня есть 4 вкладки, которые я загружаю с помощью TabHost и TabWidget, используя следующий макет:

<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:padding="0dp"
    android:layout_margin="0dp">
    <LinearLayout android:orientation="vertical"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:background="#FFFFFF" 
        android:padding="0dp"
        android:layout_margin="0dp">
        <ImageView android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:src="@drawable/titlebar" />
        <LinearLayout android:orientation="horizontal"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            android:background="#AAAAAA" 
            android:padding="0dp"
            android:layout_margin="0dp">
            <TabWidget android:id="@android:id/tabs"
                android:tabStripEnabled="true" 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>
        <FrameLayout android:id="@android:id/tabcontent"
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent"
            android:padding="0dp" 
            android:layout_margin="-5dp" />
    </LinearLayout>
</TabHost> 

Это отлично выглядит в моем эмуляторе, а также отлично смотрится на G2 моих друзей, однако на моем EVO 4G между вкладками есть странные промежутки. Между каждой из 4 вкладок, которые я загружаю, примерно 5 пикселей.
Опять же, в эмуляторе с таким же разрешением, как у EVO (800 x 480), все выглядит нормально, между вкладками нет промежутков.
Почему так? на моем EVO это выглядит по-другому?
Я перепробовал все, что мог придумать, чтобы избавиться от интервала, и ничего не работает.


person Kevin B    schedule 25.02.2011    source источник


Ответы (1)


вы можете установить цвет фона для tabwidget. см., например, следующую функцию.

    public static void setTabColor(TabHost tabhost) { 
        for(int i=0;i<tabhost.getTabWidget().getChildCount();i++){ 
     tabhost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#ff383737")); //unselected 
    } 
    tabhost.getCurrentTabView().setBackgroundColor(Color.parseColor("#ffe9e8e8"));
}}
person Tushar Vengurlekar    schedule 25.02.2011