private TabHost tabHost;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO 需要设计该Tab的UI布局super.onCreate(savedInstanceState);tabHost = this.getTabHost();LayoutInflater.from(this).inflate(R.layout.al_inpatient_detail, tabHost.getTabContentView(), true);tabHost.setBackgroundResource(R.drawable.bg_main);// 住院诊断tabHost.addTab(tabHost.newTabSpec("One").setIndicator(Constant.CENTER_INPATIENT_DIAGOSIS, getResources().getDrawable(R.drawable.center_inpatient_diagosis)).setContent(R.id.linear_diagnosis));// 费用明细tabHost.addTab(tabHost.newTabSpec("Two").setIndicator(Constant.CENTER_INPATIENT_COST, getResources().getDrawable(R.drawable.center_inpatient_cost)).setContent(R.id.linear_cost));// 结算明细tabHost.addTab(tabHost.newTabSpec("Three").setIndicator(Constant.CENTER_INPATIENT_CLEARING_FEE, getResources().getDrawable(R.drawable.center_inpatient_clearing_fee)).setContent(R.id.linear_clearing_fee));// TODO 字体颜色TabWidget tabWidget = tabHost.getTabWidget();        for (int i =0; i < tabWidget.getChildCount(); i++) {                tabWidget.setBackgroundColor(Color.WHITE);//                    tabWidget.getChildAt(i).getLayoutParams().height = 30;//设置tab的高度                     TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title);                    tv.setTextColor(Color.BLUE);//设置tab内字体的颜色        }// 点击更新背景tabHost.setOnTabChangedListener(this);tabHost.setCurrentTab(2);// TODO 查询数据,填充UI}/**     * 更新Tab标签的背景图     * @param tabHost     */    private void updateTabBackground( TabHost tabHost) {        for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {            View view = tabHost.getTabWidget().getChildAt(i);            if (tabHost.getCurrentTab() == i) {                //选中后的背景                view.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_press_click));            } else {                //非选择的背景                view.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_main));            }        }    }@Overridepublic void onTabChanged(String tabId) {// 点击更新背景updateTabBackground(tabHost);}


参考:http://www.eoeandroid.com/thread-56303-1-1.html

参考:http://www.cnblogs.com/xitang/archive/2011/09/14/2176539.html

更多相关文章

  1. Android边框背景
  2. Android ListView(Selector 颜色)
  3. [android]浅谈android的selector,背景选择器
  4. android设置系统语言,字体大小,字体样式导致widget控件失效
  5. Android RadioButton背景图片和文字的相对位置
  6. android字体大小多屏幕适配
  7. Android ListView 去除边缘阴影、选中色、拖动背景色等(转)
  8. android背景选择器selector用法、自定义Button按钮样式
  9. android spinner默认样式不支持换行和修改字体样式 的解决方法

随机推荐

  1. 获取Android设备屏幕的相关参数
  2. Android——RecyclerView入门学习之Recyc
  3. Android之BaseAdapter适配器使用技巧
  4. Android中的Activity生命周期
  5. [Android]Recovery调用外部Shell脚本,Shel
  6. Android踩坑记Caused by: com.android.to
  7. Android 自动改 Hosts工具 v1.0.1 更
  8. (原创)如何导入android中的sample例子到ec
  9. android adapter的更新
  10. android一些常用事件