When calling TabSpec.setIndicator
, the Drawable
you pass in will only be visible if the label is null
or empty. As far as making sure the TextView
is restricted to a single line goes, you could loop over TabWidget.getTabCount
, then call TabWidget.getChildTabViewAt
and View.findViewById
to get the TextView
used to set the title. After that just make a call to TextView.setSingleLine
.
final TabWidget tabWidget = tabHost.getTabWidget();
for (int i = 0; i < tabWidget.getTabCount(); i++) {
final View tab = tabWidget.getChildTabViewAt(i);
final TextView title = (TextView) tab.findViewById(android.R.id.title);
title.setSingleLine();
}
Alternatively, you could inflate your own tab layout by creating a style for Widget.TabWidget
.
<style name="Your.TabWidget" parent="@android:style/Widget.TabWidget">
<item name="android:tabLayout">@layout/your_tab_layout</item>
</style>
In your parent theme create a new item
for android:tabWidgetStyle
to apply it.