2010-11-19 40 views
3

j'ai créé un TabWidgetquel est le code équivalent pour android: layout_above = "@ android: id/tabs"?

TabWidget tabWidget = new TabWidget(this); 
     tabWidget.setId(android.R.id.tabs); 

et un FrameLayout

FrameLayout frameLayout = new FrameLayout(this); 
     frameLayout.setId(android.R.id.tabcontent); 

comment faire framelayout au-dessus des onglets?

**what is the equivalent code to "android:layout_above="@android:id/tabs"** 

EDIT

je fais avec ce code, est-il exact?

TabHost tabHost = new TabHost(this); 
tabHost.setLayoutParams(
       new RelativeLayout.LayoutParams(
         LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT,1)); 
TabWidget tabWidget = new TabWidget(this); 
     tabWidget.setId(android.R.id.tabs); 

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(width, height); 
lp.addRule(RelativeLayout.ABOVE, R.id.tabcontent); 
tabWidget.setLayoutParams(lp); 

tabHost.addView(tabWidget); 
FrameLayout frameLayout = new FrameLayout(this); 
     frameLayout.setId(android.R.id.tabcontent); 
     frameLayout.setPadding(0, 55, 0, 0); 
tabHost.addView(frameLayout, new RelativeLayout.LayoutParams(
        LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 
tabHost.setup(); 

Répondre

5
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(width, height); 
lp.addRule(RelativeLayout.ABOVE, R.id.tabcontent); 
tabWidget.setLayoutParams(lp); 
+0

hey je Dono où je me trompe! cela ne fonctionne pas pour moi! laissez-moi mettre à jour mon code – Ads

+0

suis-je manquer toute disposition relative ??? – Ads

+0

Bien sûr, vous devez utiliser un RelativeLayout ... Android: layout_above est spécifique à la façon dont il organise ses enfants. –