我通过代码设置了TabHost,没有使用布局XML。如何控制Tab显示在底部而不是顶部。通常通过XML由android:layout_alignParentBottom="true".
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
//setContentView(R.layout.main);
TabHost host=getTabHost();
host.addTab(host.newTabSpec("Offers")
.setIndicator("Offers", getResources().getDrawable(R.drawable.icon_light))
.setContent(new Intent(this, Offer_Popup.class)));
host.addTab(host.newTabSpec("Account")
.setIndicator("Account", getResources().getDrawable(R.drawable.icon_wrench))
.setContent(new Intent(this, Offer_Popup.class)));
host.addTab(host.newTabSpec("Settings")
.setIndicator("Settings", getResources().getDrawable(R.drawable.icon_user))
.setContent(new Intent(this, Offer_Popup.class)));
host.addTab(host.newTabSpec("Awards")
.setIndicator("Awards", getResources().getDrawable(R.drawable.icon_list))
.setContent(new Intent(this, List_Items.class)));
}
}
我猜你是使用相对布局(因为你使用的是android:layout_alignParentBottom="true"
)。然后我认为你需要创建RelativeLayout布局参数,并将它们应用到TabWidget上,就像这样:
RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(..., ...);
rllp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
tw.setLayoutParams(rllp); //where tw is your TabWidget
在编程上相当于使用android:layout_alignParentBottom="true"