private void updateTabHost(TabHost tabHost) {
int count = tabHost.getTabWidget().getChildCount();
for (int i = ; i < count; i++) {
View view = tabHost.getTabWidget().getChildTabViewAt(i);
int tabHeightPx = DisplayUtil.dp2px(this, // tab高度,此处单位为dp,经过DisplayUtil后转为px然后赋值
);
view.getLayoutParams().height = tabHeightPx; // tabWidget.getChildAt(i)
final TextView tv = (TextView) view
.findViewById(android.R.id.title);
tv.setTextSize();
tv.setTextColor(this.getResources().getColorStateList(
android.R.color.white));
}
}

这是更改其tabwidget样式的方法

private void changeLayout() {
// 根据用户的点击位置的下标显示相应的fragment
tabHost.setCurrentTab(currentlayout);
} private void setFragment() {
// 通过组件的id初始化tabHost的实例
tabHost = (TabHost) findViewById(R.id.tabhost);
tabHost.setup();
// tabWidget = tabHost.getTabWidget();
// 往tabHost分别添加fragment
tabHost.addTab(tabHost
.newTabSpec("main_social")
.setIndicator(
"动态",
this.getResources().getDrawable(
R.drawable.checkbox_full_pressed))
.setContent(R.id.frag_social));
tabHost.addTab(tabHost
.newTabSpec("main_geomark")
.setIndicator(
"联系人",
this.getResources().getDrawable(
R.drawable.checkbox_full_pressed))
.setContent(R.id.frag_geomark));
tabHost.addTab(tabHost
.newTabSpec("main_timeaxis")
.setIndicator(
"动态",
this.getResources().getDrawable(
R.drawable.checkbox_full_pressed))
.setContent(R.id.frag_timeaxis)); tabHost.addTab(tabHost
.newTabSpec("main_travel")
.setIndicator(
"设置",
this.getResources().getDrawable(
R.drawable.checkbox_full_pressed))
.setContent(R.id.frag_travel)); tabHost.addTab(tabHost
.newTabSpec("main_activity")
.setIndicator(
"设置",
this.getResources().getDrawable(
R.drawable.checkbox_full_pressed))
.setContent(R.id.frag_activity)); updateTabHost(tabHost);//更新布局样式等 tabHost.setCurrentTab();// 设置默认显示布局
}

这是关联Fragment和tabWidget点击的方法,此方法放在onCreate方法内~

最新文章

  1. HDU 4067 hdoj 4067 Random Maze 最小费用流
  2. WPF学习笔记——TextBox的一些问题
  3. windows核心编程读后感(待续)
  4. [Spring] IOC - Annotation
  5. 再来说说Activity
  6. 数据缓存iOS
  7. Mysql int(11) 和 int(1)
  8. IoC容器Autofac正篇之简单实例
  9. 利用Delphi监视注册表的变化
  10. cobbler无人值守自动安装
  11. double compare 0
  12. Android四大组件应用系列——实现电话拦截和电话录音
  13. 把网卡中断绑定到CPU,最大化网卡的吞吐量(转)
  14. eclipse调试快捷键
  15. final发布48小时用户调查报告
  16. linux 开机直接进入命令行
  17. 后台web请求代码(含https,json提交)
  18. Linux下显示硬盘空间的两个命令
  19. Grunt Part 2
  20. Java多线程之“同步”

热门文章

  1. UML model refactoring: a systematic literature review
  2. socket的阻塞与非阻塞,同步与非同步
  3. MVC概述
  4. python基础自学 第一天
  5. 《HTTP权威指南》6-代理
  6. QEMU KVM libvirt手册(2): monitor
  7. Android JNI 学习(六):Object Operations Api
  8. MyBatis 的动态 SQL 使用说明
  9. HTML页面中插入CSS样式的三种方法
  10. dubbo实用知识点总结(一)