问题
I am stuck in my xml code
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
I am trying to change the width to a custom set dip number but
android:layout_width="50dip"
is not making any affect to the tab width layout any suggenstion on this one please ?
Here is the full XML file Layout on pasteBin
http://pastebin.com/7vi4Pi8Z
Thanks Shiraz
回答1:
No body contributed the answer but after few hours of struggle i have found the way to set the width of tabs in java code... here you go, if some one may need this later
TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
final int tabChildrenCount = tabWidget.getChildCount();
for (int i=0; i< tabChildrenCount; i++)
{
// change the value 110 to whatever suits you for tab width
tHost.getTabWidget().getChildAt(i).getLayoutParams().width = 110;
}
many thanks shiraz
回答2:
If you don't need each tab different size, then simplest width reduction may be adding something like
android:weightSum="5"
to your TabWidget parameters.
来源:https://stackoverflow.com/questions/6428602/tab-layout-width