For your reference, if the TabWidget's parent layout is LinearLayout, you may also need to set the weight of the LayoutParams child layout. Since tabs stretch their width in my case, since its default weight is 1.0.
((LinearLayout.LayoutParams)mTabHost.getTabWidget().getChildAt(i).getLayoutParams()).weight = 0;
source share