ActionBar Вкладки вес / ширина - PullRequest
0 голосов
/ 02 февраля 2012

У меня есть панель действий с 3 вкладками.Это выглядит так: |Все |Звонки |Сеть |Я хочу, чтобы они имели одинаковую ширину.Как я могу это сделать?

Ответы [ 3 ]

2 голосов
/ 02 февраля 2012

Вы можете установить тег для любого представления, используя метод setCustomView () на ActionBar.Tab.Вот как я это сделал.Пользовательское представление загружается из макета, который в моем случае был похож на встроенный макет, используемый ActionBar.Tag, вы устанавливаете поля, размеры и контент на все, что вам нужно.

0 голосов
/ 14 июля 2014

https://groups.google.com/forum/#!topic/actionbarsherlock/4oT9KwhB0O8 Это точное решение, которое я искал несколько дней

0 голосов
/ 02 февраля 2012

Они все выровнены в строке с одинаковой шириной

<?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);
...