TabWidget 中文字居中对齐

来源:互联网 发布:手机知乎网页打不开 编辑:程序博客网 时间:2024/05/02 00:53

原帖链接http://www.eoeandroid.com/thread-73761-1-1.html    


 TabWidget tabWidget = tabHost.getTabWidget();

        
        for (int i = 0; i < tabWidget.getChildCount(); i++) {
              View child = tabWidget.getChildAt(i);

           
             final TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title);
             RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) tv.getLayoutParams();
             params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); //取消文字底边对齐
             params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); //设置文字居中对齐
             

         }
原创粉丝点击