Android - Remove Icon from TabHost/TabWidget
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.
开发者_C百科Thanks in advance.
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);
}
}
精彩评论