在TabHost中更改文本对齐方式

时间:2013-12-06 20:21:52

标签: android tabs alignment

原始问题:

有没有办法更改tabhost指示器的文本对齐方式?我希望文本正确浮动。怎么做?

编辑:这是我为实现它而实施的。

RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rllp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

int current = mTabHost.getCurrentTab();
for(int i=0;i<mTabHost.getTabWidget().getChildCount();i++)  
{  
    TextView txt = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
    txt.setLayoutParams(rllp);
    txt.setGravity(Gravity.RIGHT);
}

1 个答案:

答案 0 :(得分:0)

使用setIndicator()TabHost.TabSpec的版本View,并提供您自己的指标视图,文本按您认为合适的方式对齐。