Search code examples
androidtabsactionbarsherlockandroid-actionbar

Set tab above action bar


I have some issues with action bar and tabs navigation. Actually I want to set my tabs to be above my Action Bar. (I used Sherlock Action Bar).

I saw that some people had problems because when they enable did :

ab.setDisplayShowTitleEnabled(false);

Tabs of their tabhost was above their ActionBar but it's exactly what I want. Here is my code :

ActionBar ab = getSupportActionBar();
//getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ab.setCustomView(R.layout.action_wifisettings);
ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

ab.setDisplayShowTitleEnabled(false);
ab.setDisplayShowHomeEnabled(false);
ab.setDisplayUseLogoEnabled(false);
ab.setDisplayShowCustomEnabled(true);

and the xml file corresponding to my action bar :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="bottom">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#FFFFFF"
        android:text="@string/wifi_title"
        android:layout_marginLeft="10dp"
        android:id="@+id/action_page_title"
        android:layout_centerVertical="true"
        android:textSize="16sp" />

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/action_page_title"
        android:layout_marginLeft="40dp"
        android:textColor="#FFFFFF"
        android:layout_centerVertical="true"
        android:text="@string/checkbox_title"
        android:id="@+id/action_checkbox_wifi"
        android:textSize="16sp" />

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dp"
        android:layout_centerVertical="true"
        android:contentDescription="@string/wifi_refresh_desc"
        android:background="@drawable/ic_refresh_selector"
        android:id="@+id/action_wifi_refresh"
        android:textSize="12sp" />

</RelativeLayout>

If you know how to set my action bar to be behind my tabs it could be great. Thanks.


Solution

  • I didn't find a way to do this with the action bar so I had to implement my own view with informations I wanted.