是否可以在 TabHost/TabWidget 中删除图标(指示符)和文本与 Tab 顶部之间的空格?我只想显示文本,但我不能。
提前致谢。
最佳答案
将 TextView 与相关文本一起传递给 setIndicator(View v) 方法。如果您想要丰富的样式,我建议您将自己的“Tab”模型作为参数传递。
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 中删除图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7152180/