Search code examples
androidactionbarsherlockandroid-tabs

custom menu based on TabsAdapter with SherlockFragmentActivity


i am trying to add a custom menu based on TabsAdapter with SherlockFragmentActivity.

what i want to do

currently i have tab menu with 4 tabs, i want to add an custom image (marked as green circle) that overlay the entire menu and the tab

any idea how it can be done?


Solution

  • i found a solution:

    add 4 tabs to TabsAdapter add a layout margin to second tab:

        Display display = getWindowManager().getDefaultDisplay();
        int width = display.getWidth();
        int heigth = mTabHost.getTabWidget().getChildAt(0).getLayoutParams().height;
        mTabHost.getTabWidget().getChildAt(0).setLayoutParams(new LinearLayout.LayoutParams((width / 5), heigth));
        mTabHost.getTabWidget().getChildAt(1).setLayoutParams(new LinearLayout.LayoutParams((width / 5), heigth));
    
        View currentView = mTabHost.getTabWidget().getChildAt(1);
        LinearLayout.LayoutParams currentLayout = (LinearLayout.LayoutParams) currentView.getLayoutParams();
        currentLayout.setMargins(0, 0, width / 5, 0);
    
        mTabHost.getTabWidget().getChildAt(2).setLayoutParams(new LinearLayout.LayoutParams((width / 5), heigth));
        mTabHost.getTabWidget().getChildAt(3).setLayoutParams(new LinearLayout.LayoutParams((width / 5), heigth));