【发布时间】:2010-11-19 21:21:30
【问题描述】:
我已经创建了一个 TabWidget
TabWidget tabWidget = new TabWidget(this);
tabWidget.setId(android.R.id.tabs);
和一个框架布局
FrameLayout frameLayout = new FrameLayout(this);
frameLayout.setId(android.R.id.tabcontent);
如何在标签上方制作框架布局?
**what is the equivalent code to "android:layout_above="@android:id/tabs"**
编辑
我正在处理这段代码,它正确吗?
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();
【问题讨论】: