当时用FragmentTabHost 的 setIndicator() 方法时,采用
setIndicator(CharSequence label, Drawable icon)可能出现只显示文字不显示图片的情况,此时可以采用一下方法解决:
1.将第一个参数设置为一个空串
2.采用
setIndicator(View view)方法替代,自定义一个view作为indicator
3.通过获取每个tabview的title(其实就是一个
TextView),设置这个textview的drawable属性:
TabWidget tabWidget= (TabWidget) tabHost.findViewById(android.R.id.tabs);
View tabView= tabWidget.getChildTabViewAt(0);
TextView textView= (TextView) tabView.findViewById(android.R.id.title);
textView.setCompoundDrawablesWithIntrinsicBounds(null,getResources().getDrawable(icons[0]),null,null);