【问题标题】:Remove space between tabs in android.删除android中选项卡之间的空间。
【发布时间】:2016-05-27 19:06:39
【问题描述】:

我正在做一个标签布局。 我的问题是我的标签之间有一个小空间。

那是我的 xml:

<TabHost
    android:id="@+id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.8" >

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

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:dividerPadding="0dp"
            android:fitsSystemWindows="true"
            android:gravity="fill"
            android:orientation="horizontal"
            android:showDividers="none"
            android:visibility="visible" />

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

            <LinearLayout
                android:id="@+id/left_tab"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:showDividers="none" >

这是我的 java 代码:

public void CreateTabs(ImageView leftI, ImageView rightI, ImageView middleI, TabHost tabH) {
    leftI.setImageDrawable(getResources().getDrawable(R.drawable.btn_tab_news));
    leftI.setScaleType(ScaleType.FIT_XY);
    rightI.setImageDrawable(getResources()
            .getDrawable(R.drawable.btn_tab_calender));
    rightI.setScaleType(ScaleType.FIT_XY);
    middleI.setImageDrawable(getResources()
            .getDrawable(R.drawable.btn_tab_press));
    middleI.setScaleType(ScaleType.FIT_XY);
    tabH.setup();
    TabSpec specs = tabH.newTabSpec("tag1");
    specs.setContent(R.id.right_tab);
    specs.setIndicator(rightI);
    tabH.addTab(specs);
    specs = tabH.newTabSpec("tag2");
    specs.setContent(R.id.middle_tab);
    specs.setIndicator(middleI);
    tabH.addTab(specs);
    specs = tabH.newTabSpec("tag3");
    specs.setContent(R.id.left_tab);
    specs.setIndicator(leftI);
    tabH.addTab(specs);
}

为什么会发生这种情况,我该如何解决?谢谢!

【问题讨论】:

  • 使用 tabIndicator 发布完整代码
  • 你给我的链接是关于一个可滚动的标签小部件...我想要一个简单的标签小部件,只是没有空间。 sraven:下面是什么代码?
  • 您使用的图像可能已经有透明边框。请检查一下。
  • 我现在明白了!!它显示了9patch!为什么会显示它?

标签: android tabs space


【解决方案1】:

你需要添加这个:

<android.support.design.widget.TabLayout
    app:tabPaddingStart="0dp"
    app:tabPaddingEnd="0dp" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-19
    • 2020-11-19
    • 2017-09-04
    • 2021-11-20
    • 2011-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多