用tabhost,动态的话,下面是个参考
private void initTabs() { mTabHost = (TabHost) findViewById(R.id.tabhost);//取得host mTabHost.setup(); final TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);//用系统的tab修改 LayoutInflater inflater_tab1 = LayoutInflater.from(this); inflater_tab1.inflate(R.layout.mobile_phone_cashier_tab1, mTabHost .getTabContentView());//设置tab项xml inflater_tab1.inflate(R.layout.mobile_phone_cashier_tab2, mTabHost .getTabContentView());//置tab项xml inflater_tab1.inflate(R.layout.mobile_phone_cashier_tab3, mTabHost .getTabContentView());//设置tab项xml mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator( getString(R.string.sy)).setContent(R.id.FrameLayout01));增加tab项 mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator( getString(R.string.cd)).setContent(R.id.FrameLayout02)); mTabHost.addTab(mTabHost.newTabSpec("tab3").setIndicator( getString(R.string.jyjl)).setContent(R.id.FrameLayout03)); tabWidget.setBackgroundResource(R.drawable.tab_bg);//设置tab背景 Field mBottomLeftStrip; Field mBottomRightStrip; for (int i = 0; i < tabWidget.getChildCount(); i++) {//设置tab想的标题ICON等 final TextView tv = (TextView) tabWidget.getChildAt(i) .findViewById(android.R.id.title); tabWidget.getChildAt(i).getLayoutParams().height = 40; if (i == 0) { tabWidget.getChildAt(i).setBackgroundResource( R.drawable.tab_kuang); tv.setTextColor(Color.rgb(202, 151, 0)); } else { tabWidget.getChildAt(i) .setBackgroundResource(R.drawable.tab_bg); tv.setTextColor(Color.WHITE); tabWidget.getChildAt(i).setClickable(false); } tv.setTextSize(15); tv.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); try { //设置tab下面的横条 mBottomLeftStrip = tabWidget.getClass().getDeclaredField( "mBottomLeftStrip"); mBottomRightStrip = tabWidget.getClass().getDeclaredField( "mBottomRightStrip"); if (!mBottomLeftStrip.isAccessible()) { mBottomLeftStrip.setAccessible(true); } if (!mBottomRightStrip.isAccessible()) { mBottomRightStrip.setAccessible(true); } mBottomLeftStrip.set(tabWidget, getResources().getDrawable( R.drawable.xian)); mBottomRightStrip.set(tabWidget, getResources().getDrawable( R.drawable.xian)); } catch (Exception e) {