Android的 - 从TabHost / TabWidget删除图标 [英] Android - Remove Icon from TabHost/TabWidget

查看:162
本文介绍了Android的 - 从TabHost / TabWidget删除图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以删除图标(指标)和文本,并在TabHost / TabWidget一个标签的顶部之间的空间?我只是想diplay的文字,但我不能。

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.

先谢谢了。

推荐答案

传递一个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);
}

}

这篇关于Android的 - 从TabHost / TabWidget删除图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆