суббота, 28 апреля 2012 г.

Tips - TabWidget fixed width

I didn't find any info about TabWidget fixed with in XML.

Thats why I use this, after create TabHost and added all Tabs:

int dips = 100; //Width in dip

int pixels = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dips, getResources().getDisplayMetrics());
TabWidget widget = mTabHost.getTabWidget();
for (int i = 0; i < widget.getChildCount(); ++i) {
     View v = widget.getChildAt(i);
     v.getLayoutParams().width = pixels;

}