开发者

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);
}

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜