如何消除Android应用程序中标签之间的间距?
我使用TabHost和TabWidget加载了4个选项卡,使用以下布局:如何消除Android应用程序中标签之间的间距?,android,android-layout,Android,Android Layout,我使用TabHost和TabWidget加载了4个选项卡,使用以下布局: <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
<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(800x480)分辨率完全相同的模拟器中,它看起来很好,选项卡之间没有间隔。
为什么我的EVO看起来不一样?
我已经尝试了所有我能想到的方法来消除间距,但没有任何效果。您可以为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"));
}}
publicstaticvoidsettabcolor(TabHost-TabHost){
对于(int i=0;i