我已经研究了很多如何使用此代码对齐页面底部的选项卡,但我没有找到任何内容,我将代码用作:
public class MainActivity extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("tab1")
.setIndicator("Home")
.setContent(new Intent(this, TabGroup1Activity.class)));
tabHost.addTab(tabHost.newTabSpec("tab2")
.setIndicator("Search"/*, getResources().getDrawable(R.drawable.ic_launcher)*/)
.setContent(new Intent(this, TabGroup2Activity.class))
);
tabHost.addTab(tabHost.newTabSpec("tab3")
.setIndicator("About Us")
.setContent(new Intent(this, TabGroup3Activity.class)));
tabHost.getTabWidget().setCurrentTab(0);
tabHost.getTabWidget().setGravity(Gravity.BOTTOM);
TabGroup1Activity 是:
public class TabGroup1Activity extends TabGroupActivity{
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startChildActivity("HomeActivity", new Intent(this,HomeActivity.class));
}
}
通过使用此代码,标签栏出现在屏幕顶部,但我想将其放在底部..请提出一些建议,我发现这种方法很容易创建标签