问题
Is it possible to remove the icon (indicator) and the space between the text and the top of a Tab in a TabHost/TabWidget? I just want to diplay the text, but i can't.
Thanks in advance.
回答1:
Pass a TextView to setIndicator(View v) method with the associated text. If you want extensive styling, i suggest you pass your own "Tab" model as parameter instead.
public class Tab extends LinearLayout {
public Tab(Context c, int drawable, String label) {
super(c);
TextView tv = new TextView(c);
tv.setText(label);
tv.setTextColor(getResources().getColorStateList(R.color.tab_text_color));
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
tv.setGravity(0x01);
setOrientation(LinearLayout.VERTICAL);
if (drawable != 0) {
ImageView iv = new ImageView(c);
iv.setImageResource(drawable);
addView(iv);
}
addView(tv);
}
}
来源:https://stackoverflow.com/questions/7152180/android-remove-icon-from-tabhost-tabwidget