问题
I want to reproduce this tab indicator structure (screen is from nova launcher): a dropdown menu and an arrow in the right bottom corner.

I have no problem about code but i can't reproduce this appearance. I tried this:
mBar.addTab(mBar.newTab().setText(ctx.getString(R.string.tab_actions)).setTabListener(this).setCustomView(R.layout.navigation_spinner));
where mBar is sherlock support actionBar.
This is my layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_margin="-10dp"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<Button android:id="@+id/button1" android:layout_width="match_parent"
android:layout_height="match_parent" android:text="Button" />
</LinearLayout>
and this is my result:

The problem is that the button in the central tab doesn't fill the tab indicator. How can i set a custom view that perfectly fill the indicator without margin or padding? Or i have to approach this in a different way to have the a result like the firs screen? Thanks in advice
回答1:
What you are trying to do is really complicated, and will be hard to achieve.
If you want drop down menus you can try those :
menu/options.xml:
<item
android:icon="@drawable/ic_menu_sort"
android:showAsAction="ifRoom">
<menu>
<item
android:id="@+id/menuSortNewest"
android:title="Sort by newest" />
<item
android:id="@+id/menuSortRating"
android:title="Sort by rating" />
</menu>
</item>
Second option:
menu/options.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menuSort"
android:showAsAction="ifRoom"
android:actionLayout="@layout/action_sort" />
</menu>
layout/action_sort.xml:
<Spinner xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_menu_refresh"
android:entries="@array/order" />
Docs for menu resources - http://developer.android.com/guide/topics/resources/menu-resource.html
来源:https://stackoverflow.com/questions/12680599/custom-tab-indicator-view