Connor Tumbleson
Connor Tumbleson

Reputation: 3330

Tabhost bottom border line android

screenshot

Notice that little tiny gray line that runs underneath the tabs (Except selected tab)? How do I change/alter that?

Would that be part of the FrameLayout, tabHost or TabWidget? I just cannot find a way to alter or remove this little gray line.

Thanks

Upvotes: 4

Views: 8750

Answers (4)

http
http

Reputation: 21

I had the same problem. I searched on Stackoverflow and Google many times but there were no answers. Now I solved it. This is how:

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

tab_strip is png image (width:50px,height:2px)

Upvotes: 2

John Feagans
John Feagans

Reputation: 409

Here is a much simpler way to remove that gray line. Add this to the TabWidget in your layout:

android:tabStripEnabled="false"

Upvotes: 11

Ramindu Weeraman
Ramindu Weeraman

Reputation: 224

Create tabindicator.xml as following.

Then insert following code in to your TabActivity class. ...

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)))

In here you can change tabindicator.xml according to your requirement.

<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>

Upvotes: 5

Ramindu Weeraman
Ramindu Weeraman

Reputation: 224

This is 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/>

Upvotes: 1

Related Questions