我使用ActionBar.Tab setCustomView()方法,用這個佈局:的Android ActionBar.Tab setCustomView()不FILL_PARENT
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background_grey" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Test Tab"
android:textColor="@color/background_dark_green"/>
</RelativeLayout>
這是我的功能設置動作條:
public void setActionBar()
{
ActionBar actionBar = getSupportActionBar();
//actionBar.hide();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
//set action bar navigation mode
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
//set tabs
//home tab
Tab tab = actionBar.newTab().setText(TAB_HOME).setTabListener(new PicoTabListener<StartFragment>(this, StartFragment.class));
tab.setCustomView(R.layout.tab_background);
actionBar.addTab(tab);
//events tab
tab = actionBar.newTab().setText(TAB_EVENTS).setTabListener(new PicoTabListener<EventsFragment>(this, EventsFragment.class));
actionBar.addTab(tab);
//enter event code
tab = actionBar.newTab().setText(TAB_CODE).setTabListener(new PicoTabListener<EnterCodeFragment>(this, EnterCodeFragment.class));
actionBar.addTab(tab);
}
和我的活動佈局:
<?xml version="1.0" encoding="utf-8"?>
<!-- This is the main layout of the application -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_basic_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background_dark_green" >
</RelativeLayout>
結果接縫看起來像這樣(帶有灰色背景的左上角的標籤):
如何讓我的自定義視圖填充整個選項卡並正常工作?
我使用的是支持包V7的Android 2.3
請您發表您的活動XML佈局? – nio
完成。我已更新我的問題 –