2010-11-03 37 views
0

J'ai une disposition d'onglets avec des ressources pouvant être dessinées en tant qu'images d'onglet. En mode paysage tout va bien. Mais en mode portrait, les images n'ont pas de marge. Comment puis-je changer l'échelle des images ou comment définir une marge pour l'image? Je ne veux pas utiliser la taille fixe, ne pense pas que c'est la bonne façon.Comment modifier l'échelle d'une image tabulaire

Voici ma mise en page

<TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       /> 
     <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:padding="5dp" 
       > 
      <ListView 
        android:id="@+id/list" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        /> 
     </FrameLayout> 


<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@drawable/logo" android:state_selected="true" /> 
    <item android:drawable="@drawable/logo_disabled" /> 
</selector> 

Voici l'onglet création

Drawable d = res.getDrawable(R.drawable.logos); 
    spec = tabHost.newTabSpec(1).setIndicator("", res.getDrawable(R.drawable.logos)).setContent(intent); 
    tabHost.addTab(spec); 

Répondre

3

Résolu mon problème moi-même

//set icons padding 
    for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++){ 
     tabHost.getTabWidget().getChildAt(i).setPadding(10,10,10,10); 
    }