看如下代码:

  mTabHost = (TabHost) findViewById(R.id.tabhost);        mTabHost.setup();        final TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);        LayoutInflater inflater_tab1 = LayoutInflater.from(this);        inflater_tab1.inflate(R.layout.mobile_phone_cashier_tab1, mTabHost                .getTabContentView());        inflater_tab1.inflate(R.layout.mobile_phone_cashier_tab2, mTabHost                .getTabContentView());        inflater_tab1.inflate(R.layout.mobile_phone_cashier_tab3, mTabHost                .getTabContentView());        // inflater_tab1.inflate(R.layout.mobile_phone_cashier_tab4, mTabHost        // .getTabContentView());        // inflater_tab1.inflate(R.layout.mobile_phone_cashier_tab5, mTabHost        // .getTabContentView());        // inflater_tab1.inflate(R.layout.mobile_phone_cashier_tab1_request,        // mTabHost        // .getTabContentView());        mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator(                getString(R.string.sy)).setContent(R.id.FrameLayout01));        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));        // mTabHost.addTab(mTabHost.newTabSpec("tab4").setIndicator(        // getString(R.string.yye)).setContent(R.id.FrameLayout04));        // mTabHost.addTab(mTabHost.newTabSpec("tab5").setIndicator(        // getString(R.string.jyjl)).setContent(R.id.FrameLayout05));        tabWidget.setBackgroundResource(R.drawable.tab_bg);        Field mBottomLeftStrip;        Field mBottomRightStrip;        for (int i = 0; i < tabWidget.getChildCount(); i++) {            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);        } 

原理就是更改系统自带的tabwidget

更多相关文章

  1. Android代码实现飞行模式的打开
  2. android 監聽系統屬性變化的方法
  3. Android监听WebView滑动到底部
  4. android开发实战!2021年Android技术下半场在哪?含泪整理面经
  5. git新建本地仓库关联远程仓库(无需移动本地仓库文件)
  6. 开源分享!2021年最新 Android(安卓)资料汇总,从小白到大佬的进阶之
  7. 改变 Android(安卓)EditText 的边框
  8. Android(安卓)Activity设置全屏
  9. android 多线程下载原理

随机推荐

  1. Android应用程序内存分析-Memory Analysi
  2. Android(安卓)SDK 2.2 开发环境搭建
  3. Android(安卓)- 文件读写操作 总结
  4. Android(安卓)学习之 SQLite操作
  5. android Wifi自动连接
  6. Ubuntu环境下下载编译Android(安卓)kerne
  7. Android高手进阶教程(七)之----Android(
  8. Android开机启动Service或Activity或应用
  9. Android(安卓)ViewPager多页面滑动切换以
  10. Xamarin Mono For Android(安卓)4.6.0700