且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android的 - 从TabHost / TabWidget删除图标

更新时间:2023-01-27 18:41:29

传递一个TextView到setIndicator(视图V)方法相关的文本。如果你想丰富的造型,我建议你通过自己的标签的模式作为参数来代替。

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

}