2010-11-19 6 views
4

screenshotTabhost ligne frontière fond android

Notez que toute petite ligne grise qui court sous les onglets (sauf onglet sélectionné)? Comment puis-je changer/modifier cela?

Cela ferait-il partie de FrameLayout, tabHost ou TabWidget? Je ne peux pas trouver un moyen de modifier ou d'enlever cette petite ligne grise.

Merci

Répondre

5

Créer tabindicator.xml comme suit. Puis insérez le code suivant dans votre classe TabActivity.

...

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

Ici vous pouvez changer tabindicator.xml selon vos besoins.

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

Ceci est 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/> 
11

Voici une façon beaucoup plus simple de supprimer cette ligne grise. Ajoutez ceci au TabWidget dans votre disposition:

android:tabStripEnabled="false" 
+0

Simple et facile à mettre en œuvre! Merci! – Ahmed

2

J'ai eu le même problème. J'ai cherché sur Stackoverflow et Google plusieurs fois, mais il n'y avait pas de réponses. Maintenant, je l'ai résolu. Voici comment:

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

tab_strip est l'image .png (largeur: 50px, hauteur: 2px)