2012-02-02 44 views

回答

2

可以使用在动作条setCustomView()方法的标签设置为任何看法。标签。这是我做到的。自定义视图是从一个布局加载的,在我的情况下,它与ActionBar.Tag使用的内置布局类似,您可以根据需要设置边距,大小和内容。

+0

我会试试看。谢谢。 – 2012-02-02 16:05:20

+0

有用吗,乌列尔先生? – habitats 2014-06-30 20:13:27

0

他们所有的行对准相同的宽度

<?xml version="1.0" encoding="utf-8"?> 
<TabHost 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@android:id/tabhost" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
<HorizontalScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:fillViewport="true" 
    android:scrollbars="none"> 
<TabWidget 
    android:id="@android:id/tabs" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"/> 
</HorizontalScrollView> 
<FrameLayout 
    android:id="@android:id/tabcontent" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 
</LinearLayout> 
</TabHost> 

然后设置选项卡主机

TabHost tabHost; 
TabHost.TabSpec spec; 
tabHost=getTabHost() 
Intent intent; 
intent=new Intent().setClass(this, BirthDayTab.class); 
spec=tabHost.newTabSpec("artists").setIndicator("BirthDay",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent); 
tabHost.addTab(spec); 
+2

号你说的是常规选项卡中的精确解。我正在谈论** ActionBar Tabs ** – 2012-02-02 13:27:39