2010-11-21 45 views
1

J'écris du code java pour créer des tabs. Je l'ai fait. Mais maintenant je veux que le widget de l'onglet soit dans la partie inférieure de l'écran. J'espère que cela sera obtenu en ajoutant ce code. android:layout_alignParentBottom="true" laissez-moi savoir comment ajouter ce codage.Je veux un aspect similaire à celui-ci http://android-pro.blogspot.com/2010/08/iphone-like-tab-bar-in-android.htmlcomment ajouter parent align pour l'onglet TabWidget?

TabHost tabHost = new TabHost (this);

tabHost.setLayoutParams(
      new LinearLayout.LayoutParams(
        LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 
    RelativeLayout rl=new RelativeLayout(ContactManager.this); 

    RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); 

    rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, android.R.id.tabs); 
    rl.setLayoutParams(rlp); 
    tabHost.addView(rl); 

    TabWidget tabWidget = new TabWidget(this); 
    tabWidget.setId(android.R.id.tabs); 
    rl.addView(tabWidget, new LinearLayout.LayoutParams(
       LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 

    FrameLayout frameLayout = new FrameLayout(this); 
    frameLayout.setId(android.R.id.tabcontent); 
    frameLayout.setPadding(0, 55, 0, 0); 


    rl.addView(frameLayout, new LinearLayout.LayoutParams(
       LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 
    tabHost.setup(); 

Répondre

1

Faites votre mise en page avec XML c'est beaucoup plus facile. Vous aurez besoin d'images à onglets faites sur mesure, car celles qui sont en stock ne sont pas exactement au bas de l'écran.

+0

merci! J'ai fait cela et j'ai obtenu la sortie. – Ads