截屏

请注意,在选项卡下方的小灰色线(选择选项卡除外)?如何更改/改变它?

这是Framelayout,Tabhost还是TabWidget的一部分?我只是找不到更改或删除这条小灰色线的方法。

谢谢

有帮助吗?

解决方案

创建tabindicator.xml如下。

然后将以下代码插入到您的表格类中。 ...

View indicator1 = getLayoutInflater().inflate(R.layout.tabindicator,
    null);
  im1 = (ImageView) indicator1.findViewById(R.id.icon);
  im1.setBackgroundDrawable(getResources().getDrawable(
    R.drawable.home));

  View indicator2 = getLayoutInflater().inflate(R.layout.tabindicator,
    null);
  im2 = (ImageView) indicator2.findViewById(R.id.icon);
  im2.setBackgroundDrawable(getResources().getDrawable(
    R.drawable.account));

mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator(
    indicator1).setContent(new Intent(this, Home.class)));

  mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator(
    indicator2)
    .setContent(new Intent(this, Accounts.class)))

在这里,您可以根据您的要求更改Tabindicator.xml。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
  <ImageView android:id="@+id/icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"/>
</RelativeLayout>

其他提示

这是删除该灰色线的一种简单的方法。将其添加到布局中的TabWidget:

android:tabStripEnabled="false"

我有同样的问题。我在Stackoverflow和Google上搜索了很多次,但没有答案。现在我解决了。这就是:

tabWidget.setRightStripDrawable(R.drawable.tab_strip);
tabWidget.setLeftStripDrawable(R.drawable.tab_strip);

tab_strip 是PNG图像(宽度:50px,高度:2PX)

这是Tabindicator.xml。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">

<ImageView android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />

<RelativeLayout/>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top