0

3つのタブがあるアクションバーがあります。次のようになります。すべて| 呼び出し| ネットワーク| 同じ幅にして欲しいです。どうすればいいですか?

4

3 に答える 3

2

ActionBar.TabのsetCustomView()メソッドを使用して、任意のビューにタグを設定できます。これが私がやった方法です。カスタムビューは、私の場合はActionBar.Tagで使用される組み込みのレイアウトに似たレイアウトから読み込まれ、余白、サイズ、コンテンツを必要に応じて設定します。

于 2012-02-02T15:55:02.003 に答える
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);
于 2012-02-02T12:52:27.270 に答える
-1

https://groups.google.com/forum/#!topic/actionbarsherlock/4oT9KwhB0O8 これは私が何日も探していた正確なソリューションです

于 2014-07-14T12:51:41.387 に答える